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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a factorial program using C.

643


What are the advantages and disadvantages of pointers?

578


What are operators in c?

583


Why can’t we compare structures?

814


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

1587






How can you determine the maximum value that a numeric variable can hold?

641


What does typedef struct mean?

662


How can you convert integers to binary or hexadecimal?

616


What are valid operations on pointers?

668


Is c procedural or functional?

586


What is strcmp in c?

598


What is the mean of function?

649


Differentiate Source Codes from Object Codes

822


Explain what is the benefit of using an enum rather than a #define constant?

723


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1743