Write a program to find given number is even or odd without
using any control statement.

Answers were Sorted based on User's Feedback



Write a program to find given number is even or odd without using any control statement...

Answer / rani

#include<stdio.h>
#include<conio.h>
void main()
{
char str[][10]={"even","odd"};
int no;
clrscr();
printf("\nEnter a number...");
scanf("%d",&no);
printf("\n%d is %s",no,str[no%2]);
getch();
}

Is This Answer Correct ?    13 Yes 1 No

Write a program to find given number is even or odd without using any control statement...

Answer / saneemask

main()
{

{
char a[][5]= {"Even","Odd"};
int n;
printf("Enter any no.: ");
scanf("%d",&n);
printf("%s",a[n%2]);
getch();
}
{

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Interview Questions

Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL

0 Answers  


What is the difference between #include <header file> and #include “header file”?

0 Answers  


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)

2 Answers   HCL, IBM, Satyam, Vimal, Vimukti Technologies,


int i =10 main() { int i =20,n; for(n=0;n<=i;) { int i=10 i++; } printf("%d", i);

6 Answers   HCL, Octal, SW,


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

0 Answers  






Explain what does the format %10.2 mean when included in a printf statement?

0 Answers  


What is the advantage of an array over individual variables?

0 Answers  


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

0 Answers  


If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..

0 Answers   IBM, Wipro,


Discuss similarities and differences of Multiprogramming OS and multiprocessing OS?

4 Answers   TCS,


Write a C++ program without using any loop (if, for, while etc) to print numbers from 1 to 100 and 100 to 1;

18 Answers   Accenture, Cisco, Egentec, HCL, Ideaz, Infosys, M-Systems, MYR, TCS,


Function calling procedures? and their differences? Why should one go for Call by Reference?

0 Answers   ADP,


Categories