write a c program to print a given number as odd or even
without using loop statements,(no if ,while etc)
Answer Posted / p.thirugnanavel
#include<stdio.h>
#include<conio.h>
void main()
{
int no,ch;
clrscr();
printf("enter the number :");
scanf("%d",&no);
ch=(no%2==0) ? (1) : (2);
switch(ch)
{
case 1:
printf("The number %d is even",no);
break;
case 2:
printf("The number %d is odd",no);
break;
}
getch();
}
| Is This Answer Correct ? | 7 Yes | 5 No |
Post New Answer View All Answers
How do you determine whether to use a stream function or a low-level function?
What is a 'null pointer assignment' error?
Can you tell me how to check whether a linked list is circular?
Why functions are used in c?
What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }
What will be the outcome of the following conditional statement if the value of variable s is 10?
What does & mean in scanf?
What is a protocol in c?
Can I initialize unions?
What functions are used for dynamic memory allocation in c language?
Write a program to reverse a given number in c?
What is the heap in c?
What is an array in c?
What library is sizeof in c?
Which of these functions is safer to use : fgets(), gets()? Why?