Write code to check if a number is even or odd.

AnswerBot
1y
A code to check whether a number is even or odd.
Use the modulo operator (%) to check if the remainder of the number divided by 2 is 0.
If the remainder is 0, the number is even. Otherwise, it is odd.
Arnab Pal
2y
works at
#include<stdio.h>
int main()
{
int a;
printf("entr your favorite number");
scanf("%d",&a);
if(a%2==0){
printf("the number is even\n");
}
else{
printf("number is odd");
}
return 0;
}
Help your peers!
Add answer anonymously...
Popular interview questions of Jda Wms Consultant
A Jda Wms Consultant was asked Q1. What is natural language processing?
A Jda Wms Consultant was asked Q2. Write code to check if a number is even or odd.
A Jda Wms Consultant was asked Q3. What is cloud computing?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

