write a c program to print a given number as odd or even
without using loop statements,(no if ,while etc)

Answers were Sorted based on User's Feedback



write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int m;
printf("0 - odd number \t 1 - even number\n");
printf("enter the number :");
scanf("%d",&m);
printf(" %d ",m&1);
getch();
}


thank u

Is This Answer Correct ?    43 Yes 27 No

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / avinash kumar

#include<stdio.h>
main()
{
int a;
clrscr();
printf("enter a number:");
scanf("%d",&a);
if(a%2=0)
printf("even");
else
printf("odd")
getch();
}

Is This Answer Correct ?    25 Yes 22 No

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / 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

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / dheerendra

logic
main()
{
int a;
(a%2==0)?printf("even"):printf("odd")
}

Is This Answer Correct ?    4 Yes 4 No

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / manojkumar

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the number :");
scanf("%d",&a);
b=a%2;
switch(b)
{
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 ?    3 Yes 4 No

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / 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

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / taesung kim

(number & 1) ? (odd) : (even);

Is This Answer Correct ?    5 Yes 10 No

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / vignesh1988i

sorry , just change printf() as.... printf("0 - even number \t 1 - odd number \n ");

thank u

Is This Answer Correct ?    12 Yes 19 No

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / jan

bogoon

Is This Answer Correct ?    5 Yes 15 No

write a c program to print a given number as odd or even without using loop statements,(no if ,whi..

Answer / dr:rahul

#include<stdio.h>
#include<conio.h>
void main()
{
int rahul;
printf("0 - odd number \t 1 - even number\n");
printf("enter the number :");
scanf("%d",&rahul);
printf(" %d ",rahul&1);
getch();
}

Is This Answer Correct ?    4 Yes 14 No

Post New Answer

More C Interview Questions

WAP to accept rollno,course name & marks of a student & display grade if total marks is above 200?

4 Answers  


What is the acronym for ansi?

0 Answers  


In C language, a variable name cannot contain?

0 Answers  


what are enumerations in C

0 Answers   TCS,


Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.

6 Answers  






How can you call a function, given its name as a string?

0 Answers  


Write code for finding depth of tree

2 Answers   Adobe,


what will be the output of" printf("%d%d",scanf("%d% d",&a&b));"

4 Answers  


What are the various topologies? Which one is the most secure?

2 Answers  


Can a pointer be null?

0 Answers  


what is use of loop?

10 Answers   Infosys,


what will the following program do? void main() { int i; char a[]="String"; char *p="New Sring"; char *Temp; Temp=a; a=malloc(strlen(p) + 1); strcpy(a,p); //Line no:9// p = malloc(strlen(Temp) + 1); strcpy(p,Temp); printf("(%s, %s)",a,p); free(p); free(a); } //Line no 15// a) Swap contents of p & a and print:(New string, string) b) Generate compilation error in line number 8 c) Generate compilation error in line number 5 d) Generate compilation error in line number 7 e) Generate compilation error in line number 1

1 Answers   IBM,


Categories