write a c program to find the given num is even or odd
Answers
Answered by
0
Answer:
#include <stdio.h>
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
// true if num is perfectly divisible by 2
if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);
return 0;
Answered by
2
The given code is written in C.
#include <stdio.h>
int main() {
int n;
printf("Enter a number: ");
scanf("%d",&n);
if(n%2==0)
printf("Number is even.");
else
printf("Number is odd.");
return 0;
}
A number is said to be even if it is divisible by 2 i.e., if it leaves remainder 0 when divided by 0. Using if-else statement, the problem is solved.
Attachments:
Similar questions