write a c program to print a given number as odd or even
without using loop statements,(no if ,while etc)
Answer Posted / bhabesh rai
#include<stdio.h>
main()
{
int n;
printf("Enter an integer:\n");
scanf("%d", &n);
switch((n%2 == 0) ? (1) : (2))
{
case 1:
printf("EVEN\n", n);
break;
case 2:
printf("ODD\n", n);
break;
}
}
| Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
How can I automatically locate a programs configuration files in the same directory as the executable?
What is difference between Structure and Unions?
Explain the properties of union.
What does p mean in physics?
What are pointers? What are different types of pointers?
Explain what is the general form of a c program?
Explain about the constants which help in debugging?
What does it mean when a pointer is used in an if statement?
What is null pointer in c?
In a switch statement, explain what will happen if a break statement is omitted?
What is ambagious result in C? explain with an example.
Do you know what are bitwise shift operators in c programming?
How can I find out how much free space is available on disk?
Is multithreading possible in c?
Is javascript based on c?