C Programming
What is leap year? What is if statement? How to find the year is leap year are not using c program? We will be discussing about the c program to find leap year and the other details.
what is leap year?
The leap year is the year which has 366 days per year.
It is said that leap is repeated every four year.
formula: year%4=0
What is if else statement?
It is a condition statement. If the condition is true it executes the first statement, if not (else) it will execute the second statement.
syntax:
if(condition)
{
statement-1
else
statement-2
}
C program to find leap year.
Explaination:
- Header file stdio.h - standard input and output to get input and show output, conio.h - console input and output.
- void main - function returning value will be null.
- int - declare the type of variable. where n variable represent year.
- clrscr - clear the screen.
- printf - used to print the output screen.
- scanf - used to accept input (%d), and read (&n).
- getch - used to hold the screen until the user gives any type of input.
- I have used if statement.
logic behind the program
- if statement has the condition n(year) is divided by 4, the leap year must be divisible by 4.
- If the condition is true, then the first statement that is, "year is a leap year" is printed.
- If the condition is false then the second statement that is "year is not a leap year" is printed.
Output:
here are some output for the above program.
The above program is used to find leap year. It is also an example for if-else statement.
In following days we will discuss more programs in detail. If you like to learn more just follow me regularly. If you have any question to ask mention below in comment.Thank you......


Comments
Post a Comment