find a number whether it is even or odd without using any
control structures and relational operators?

Answers were Sorted based on User's Feedback



find a number whether it is even or odd without using any control structures and relational operato..

Answer / gganesh

#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter the number : ");
scanf("%d",&n);
n%2?printf("Odd"):printf("Even");
getch();
}

note: here i used conditional operator, not a relational
operators and control structures

Is This Answer Correct ?    3 Yes 1 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / vignesh1988i

THE LAST two answers posted by two folks are correct but the
declarations have been made wrong...... we cant make use of
1D array here , if so only 'e' or 'o' only will get
printed.... but that is not our aim... so correct
declaration is using a 2D array.....
char a[][6]={{"even"},{"odd"}};

and also it is not the must to make use of array of pointers
concept...........

thank u

Is This Answer Correct ?    3 Yes 2 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / sanju uthaiah

#include<stdio.h>

int main()
{
char result[2]={"Even","Odd"};
int n=40;
printf("%d is %s",n,result[n%2]);
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / vishal jain

#include<stdio.h>
#include<conio.h>
int main()
{
int num;
printf("Enter any Number : \n");
scanf("%d",&num);
char *s[2]={"Even","Odd"};
printf("%s",s[num&1]);
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / vishal jain

#include<stdio.h>
#include<conio.h>
int main()
{
int num,i;
printf("Enter any Number : \n");
scanf("%d",&num);
i=num&1;
if(i==1)
{
printf("ODD");
}
else
{
printf("EVEN");
}
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / mohd parvez 09311349697

#include<stdio.h>
#include<conio.h>
void main()
{
int num;
printf("Enter a number:");
scanf("%d",&num);
num%2&&printf("Number is ODD")||printf("Number is EVEN");
getch();
}

Is This Answer Correct ?    1 Yes 2 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / rohit agarwal

#include<stdio.h>
#include<conio.h>
main()
{
int n;
char *p[]={"Even","odd"};
clrscr();
printf("Enter the number");
scanf("%d",&n);
n=n%2;
printf("The value is %s",p[n]);
getch();

Is This Answer Correct ?    1 Yes 2 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / om

void odd_even_check(int z)
{
(z&1)?printf("\nodd\n"):printf("\neven\n");
}

Is This Answer Correct ?    1 Yes 5 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / asad

int oddeven(int n)
{
if(n&1)
return 1; //odd

else
return 0; //even
}

Is This Answer Correct ?    2 Yes 7 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / satyanarayana

#include<stdio.h>
void main()
{
int p;
printf("number:");
scanf("%d",&p);
while(p%2)
{
printf("odd");
}
printf("even");
}

Is This Answer Correct ?    2 Yes 10 No

Post New Answer

More C Interview Questions

what is a stack

6 Answers  


What is use of pointer?

0 Answers  


7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

0 Answers  


whether itis a structured language?

1 Answers   Microsoft,


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  


to convert a string without using decrement operater and string functions

1 Answers  


When would you use a pointer to a function?

0 Answers  


What do you mean by command line argument?

0 Answers   TCS,


Why isn't any of this standardized in c? Any real program has to do some of these things.

0 Answers  


What does 3 periods mean in texting?

0 Answers  


Go through this linked list concept.While traversing through the singly linked list sometimes the following code snippet "while(head != NULL)" is used and other times "while(head->link != NULL)"is used(Here head is the pointer pointing to the first node,node has two parts data part and link part).What is the difference between head != NULL and Head->link != NULL and in which situation are they used?

1 Answers   Oracle,


What is use of integral promotions in c?

0 Answers  


Categories