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
What is difference between constant pointer and constant variable?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
What are the types of c language?
Why is #define used?
Difference between goto, long jmp() and setjmp()?
How can I sort a linked list?
What is the difference between call by value and call by reference in c?
How is = symbol different from == symbol in c programming?
What is the difference between mpi and openmp?
Write a code to remove duplicates in a string.
Explain what are compound statements?
Write the control statements in C language
Explain the priority queues?
code for quick sort?