answersLogoWhite

0


Best Answer

#include
#include
void main()
{
int n;
clrscr();
printf("\nEnter the year:");
scanf("%d",&n);
if((n%400==0)((n%4==0)&&(n%100!=0)))
printf("Leap Year");
else
printf("Not a Leap Year");
getch();
}

output:

Enter the year:2003
Not a Leap Year
Enter the year:1312
Leap Year
Enter the year:1300
Not a Leap Year
Enter the year:1600
Leap Year

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

#include #include
int main()
{
int yr,n;
clrscr();
printf("\nPROGRAM TO CHECK IF THE GIVEN YEAR IS LEAP\n");
printf("Enter the year(example:1989):");
scanf("%d",&yr);
if(yr!=0)
{
n=yr%100;/*Extract tens and units place value*/
if((n%4)==0)
printf("\n%d IS A LEAP YEAR\n",yr);
else
printf("\n%d IS NOT A LEAP YEAR",yr);
}
else
{
printf("\nINVALID INPUT\n");
exit(1);
}
return 0;
getch();
}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

# store year
yy=0
isleap="false"

echo -n "Enter year (yyyy) : "
read yy

# find out if it is a leap year or not

if [ $((yy % 4)) -ne 0 ] ; then
: # not a leap year : means do nothing and use old value of isleap
elif [ $((yy % 400)) -eq 0 ] ; then
# yes, it's a leap year
isleap="true"
elif [ $((yy % 100)) -eq 0 ] ; then
: # not a leap year do nothing and use old value of isleap
else
# it is a leap year
isleap="true"
fi
if [ "$isleap" == "true" ];
then
echo "$yy is leap year"
else
echo "$yy is NOT leap year"
fi



Check bellow link for other methods

http://bashscript.blogspot.com/2009/11/shell-script-to-check-whether-given.html

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

10 CLS: PRINT "Type the year you're interested in:"; : Input yr

20 Leap$ = "No"

30 If Int(yr/4) = yr/4 then Leap$ = "Yes"

40 If Int(yr/100) = yr/100 then Leap$ = "No"

50 If Int(yr/400) = yr/400 then Leap$ = "Yes"

60 PRINT: PRINT "Is the year"; yr; "a leap year ?"; " "; Leap$

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

First goto notepad and type in commands (each on their own line) as you would in command prompt. Then save the file as a batch file (.bat). Your file is now executable.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Simple program to check whether a given year is leap year or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Could you write a assembly language program in tasm To check whether a given number present in a sequence of given memory location containing the string to be checked in 8086?

8086 assembly language program to check wether given number is perfect or not


Lab manual in mca 1st sem from ignou?

write a program in C to check whether a given number is apalindrome or not


To check whether the given number is an Avogadro number or not?

45


Program to check whether the entered number is even or odd?

#include<stdio.h> #include<conio.h> void main() { int n; printf("ENTER NO FOR CHECK........ "); scanf("%d", &n); if(n%2==0) printf("Given No is EVEN"); else printf("Given No is ODD"); getch(); }


How can you tell if the product of two fractions will be in simpilist form before you use mulitiplication Use examples?

consider a/b * c/d check whether a/b and c/d are in simplest form. if not make them.. if they are then check whether a/d and c/b are in simple form. if no make them. if they are then the answer is going to be a simple fraction. example 3/8 * 12/5 the given fractions are already in simple form. now check whether 3/5 and 12/8 are in simple form. 12/ 8 is not in simple form. so canceling the multiple 4 12/8 = 3/2 now all fractions are simple therefore now the multiplication becomes 3/2 * 3/5 = 9/10


How do you calculate sum of digit of a given three digit number in visual basic?

simple program


How can you write a complete fortran program to calculate a simple interest siprt100 given principal rate and time?

Solve simple intress usin fortran


Draw a flow chart to check whether a given number is prime or not?

[object Object]


Shell program for gcd of three given numbers?

write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html


Method to check the given number is perfect square?

Simple and easy solution:- http://codepad.org/svhkJpxp


Write an algorithm to check whether the given number is odd or even?

Type your answer here... i think we should first enter 1 number then check it


Write a Java Program to find occurences of given word in a text?

Check the documentation of the String class, for a method that searches for a substring.