1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
balandron [24]
3 years ago
9

6.31 LAB: Leap year - functions A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer

to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is:
Computers and Technology
2 answers:
Gnesinka [82]3 years ago
7 0

Answer:

The code is given below in C with appropriate comments

Explanation:

#include <stdio.h>

#include <stdbool.h>

bool ISLeapYear(int userYear)

{

  // If a year is multiple of 400,

  // then it is a leap year

  if (userYear % 400 == 0)

      return true;

  // Else If a year is multiple of 100,

  // then it is not a leap year

  if (userYear % 100 == 0)

      return false;

  // Else If a year is multiple of 4,

  // then it is a leap year

  if (userYear % 4 == 0)

      return true;

  return false;

}

int main(void) {

  int year;

  printf("Enter year : ");

  scanf("%d",&year);

  if(ISLeapYear(year)){

      printf("%d is a leap year.",year);

  }else{

      printf("%d is not a leap year.",year);

  }

  return 0;

satela [25.4K]3 years ago
4 0

Answer:

#include <iostream>

using namespace std;

int main()

{

   int detect_year;

   cout << "Enter a year to find whether its leap year or not: ";

   cin >> detect_year;

   if (detect_year % 4 == 0)

   {

       if (detect_year % 100 == 0)

       {

           if (detect_year % 400 == 0)

               cout << "The year you entered "<< detect_year << " is a leap year.";

           else

               cout << "The year you entered "<<detect_year<< " is not a leap year.";

       }

       else

           cout << "The year you entered "<< detect_year << " is a leap year.";

   }

   else

       cout << "The year you entered "<<detect_year<<" is not a leap year.";

   return 0;

}

Explanation:

first make a variable named as detect_year of time integer. The using cin ask the user to enter any year to find out whether its leap year or not. Once the user has entered the year the value is stored in detect_year variable. After the divide the year by 4 if the remainder is not zero then it is not a leap year. If it is divisible by 4 which means the remainder is zero the divide the year by 100. If the remainder is not zero means it is not divisible by 100 then its a leap year. If it is divisible by 100 then check whether the year is divisible by 400 if yes then it is leap year other wise it is not.

You might be interested in
Pls answer this
trapecia [35]

Answer:

It looks like an Acme thread.

Explanation:

5 0
3 years ago
Provide an example of making multiple paragraphs tags using html and at least 3 sentences.
DiKsa [7]

Answer:

<p> tag:

The <p> tag in HTML defines a paragraph. These have both opening and closing tag. So anything mentioned within <p> and </p> is treated as a paragraph. Most browsers read a line as a paragraph even if we don’t use the closing tag i.e, </p>, but this may raise unexpected results. So, it is both a good convention and we must use the closing tag.

Syntax:

<p> Content </p>  

Example:

<!DOCTYPE html>  

<html>  

<head>  

   <title>Paragraph</title>  

</head>  

<body>  

   <p>A Computer Science portal for geeks.</p>  

   <p>It contains well written, well thought articles.</p>  

</body>  

</html>

Output:

A computer Science Portal for geeks.

It contains well written, well thought articles.

6 0
3 years ago
How are procedural and object-oriented programming approaches similar?
masya89 [10]

Answer:

A. Both approaches are used when writing programs.

Explanation:

Procedural programming (PP), also known as inline programming takes a top-down approach. It is about writing a list of instructions to tell the computer what to do step by step. It relies on procedures or routines. Object-oriented programming (OOP) is about encapsulating data and behavior into objects.

Hope this helps....

Have a nice day!!!!

4 0
3 years ago
A unique aspect of Java that allows code compiled on one machine to be executed on a machine of a different hardware platform is
notka56 [123]

Answer:

Java's bytecode

Explanation:

To execute its operations, java programming languages uses bytecodes.

These bytecodes are literally instructions of a java virtual machine (or JVM). They are generated in form of a class file as soon as the java program is ran and executed. In other words, the java compiler compiles the code and generates the bytecode.

As soon as the bytecode is generated, it can be transferred to a different machine and platform completely and one can run this bytecode on this different machine.

8 0
3 years ago
What is the difference between hardware and software?
DIA [1.3K]

Answer:

Computer hardware is any physical device used in or with your machine, whereas software is a collection of code installed onto your computer's hard drive. For example, the computer monitor you are using to read this text and the mouse you are using to navigate this web page are computer hardware.

Explanation:

4 0
4 years ago
Other questions:
  • Using tracking code, Google Analytics can report on data from which systems? A. E-commerce platforms.B. Mobile Applications.C. O
    11·1 answer
  • Which of the following is not one of the Fatal Four events that cause three out of five construction worker deaths? A. Caught in
    8·2 answers
  • Bgtdeberbaf raaaaaaaaaaaaaaaaaaaaa graaaaaaaaaaaaaaaaaaaaaaaaaaa
    11·1 answer
  • Diane is receiving a lot of unwanted e-mail. What steps can she take to reduce the amount of e-mail she receives?
    12·1 answer
  • Cost Benefit Analyses (CBAs) cannot be calculated after controls have been functioning for a time, as observation over time prev
    13·1 answer
  • What is the most efficient way to prevent the spelling checker from repeatedly flagging a correctly spelled name in all of your
    5·1 answer
  • In a sport like baseball, which of the following could be considered a “rule”?
    12·1 answer
  • What is node ? Briefly explain with diagram<br><br>​
    8·1 answer
  • The cost of a postsecondary education increases with the length of time involved in the program.
    10·1 answer
  • When creating a storyboard, in which section do you mention how you move from one shot to the next?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!