/*programming class problem:take a number from user
and find out the following characteristies:
1.positive or negative number?
2. even or odd numer?
3.divisible by 2?
4.leap year?
*/
#include<stdio.h>
int positive(int num);
int even_odd(int num);
int divisible(int num);
int leapyear(int num);
int main()
{
int num;
printf("Sample input:");
scanf("%d",&num);
printf("\n\nsample output:\n");
positive( num);
even_odd( num);
divisible( num);
leapyear( num);
}
int positive(int num)
{
if(num>0)
printf("\n%d is positive num.",num);
else
printf("\n%d is negative num.",num);
return 0;
}
int even_odd(int num)
{
if(num%2==0)
printf("\n%d is even num.",num);
else
printf("\n%d is odd num.",num);
return 0;
}
int divisible(int num)
{
if(num%2==0)
printf("\n%d is a divisible by 2. ",num);
else
printf("\n%d is a not divisible by 2. ",num);
return 0;
}
int leapyear(int num)
{
if(num%4==0&&num%100!=0||num%400==0)
printf("\n%d is a leap year .",num);
else
printf("\n%d is not leap year.",num);
return 0;
}
uykjuyhkjhkjhkjy
ReplyDelete