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


Please Help Members By Posting Answers For Below Questions

Explain why C language is procedural?

766


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

5790


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

655


What do you mean by Recursion Function?

627


What are structure members?

591






What is variable in c example?

590


What is ## preprocessor operator in c?

609


Why do we use c for the speed of light?

603


Explain how can I manipulate strings of multibyte characters?

778


What is c variable?

548


Can we initialize extern variable in c?

628


What is the difference between near, far and huge pointers?

628


Implement bit Array in C.

672


What is a good data structure to use for storing lines of text?

590


Describe explain how arrays can be passed to a user defined function

599