/*
** C program to check whether an entered year is a leap year or not
** @author: suresh
** @date: 14/02/02011*/
** @
http://www.go4expert.com
#include<stdio.
h>
int main
(void)
{
int year;
printf("Enter the year: ");
scanf
("%d",&year
);
/*
** The logic is that the year is either divisible by both
** 100 and 4 , OR its only divisible by 4 not by hundred
*/
if(year%
400 ==
0 ||
(year%
100 !=
0 && year%
4 ==
0))
{
printf("Year %d is a leap year",year
);
}
else
{
printf("Year %d is not a leap year",year
);
}
return 0;
}
Ascending Order Of Given Array In C
07 | printf ( "please enter 4 numbers" ); |
14 | if (num[0]<num[1] && num[0]<num[2] && num[0]<num[3]) |
16 | printf ( "\n%i" ,num[0]); |
19 | else if (num[1]<num[0] && num[1]<num[2] && num[1]<num[3]) |
21 | printf ( "\n%i" ,num[1]); |
24 | else if (num[2]<num[0] && num[2]<num[1] && num[2]<num[3]) |
26 | printf ( "\n%i" ,num[2]); |
29 | else if (num[3]<num[0] && num[3]<num[1] && num[3]<num[2]) |
31 | printf ( "\n%i" ,num[3]); |
05 | int my_array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
07 | test =sizeof my_array / sizeof my_array[0]; |
08 | printf ( "Size of my array is: %d\n" , test ); |
10 | for (count= test ; count>=0; count--) |
12 | printf ( " %d% " , my_array[count]); */ |
| |
0 comments:
Post a Comment