accept two numbers find out whether these numbers are even or odd calculate their sum
Plz I need it very fast.
Answers
Answered by
1
#include <stdio.h>
int main()
{
int a,b,c;
printf("Enter Numbers : ");
scanf("%d%d", &a,&b);
if(a % 2 == 0)
printf("%d is even.", a);
else
printf("%d is odd.", a);
printf("\n");
if(b % 2 == 0)
printf("%d is even.", b);
else
printf("%d is odd.", b);
c = a + b;
printf("\n\nSum of %d and %d = %d",a,b,c);
return 0;
}
int main()
{
int a,b,c;
printf("Enter Numbers : ");
scanf("%d%d", &a,&b);
if(a % 2 == 0)
printf("%d is even.", a);
else
printf("%d is odd.", a);
printf("\n");
if(b % 2 == 0)
printf("%d is even.", b);
else
printf("%d is odd.", b);
c = a + b;
printf("\n\nSum of %d and %d = %d",a,b,c);
return 0;
}
Answered by
0
C program for EVEN or ODD: Here, we are reading an integer number from the user and checking whether it is EVEN or ODD.
Given an integer number and we have to check it is EVEN or ODD using C program.
The numbers which are divisible by 2 are EVEN numbers and which are not divisible by 0 are not as ODD numbers.
To check whether given number is EVEN or ODD, we are checking modulus by dividing number by 2, if the modulus is 0, then it will be completely divisible by 2 hence number will be EVEN or its will be ODD.
Similar questions