Question-Any integer is input through the keyboard. Write a program to
find out whether it is an odd number or even number.
Solution-
Well, it's an easy one again. i would recommend you to wright compact codes here. that would be really helpful for you in future.
#include<stdio.h>
int main()
{
int num;
printf("Enter a number\n");
scanf("%d",&num);
num%2==0?printf("Even number\n"):printf("Odd number\n");
return 0; /*i have excluded 0, you can add it by making one if statement*/
}
find out whether it is an odd number or even number.
Solution-
Well, it's an easy one again. i would recommend you to wright compact codes here. that would be really helpful for you in future.
#include<stdio.h>
int main()
{
int num;
printf("Enter a number\n");
scanf("%d",&num);
num%2==0?printf("Even number\n"):printf("Odd number\n");
return 0; /*i have excluded 0, you can add it by making one if statement*/
}
No comments:
Post a Comment