To find whether a number is even or odd without using any
conditional operator??
Answer Posted / jai gomathi
/*PROGRAM BY JAI GOMATHI.NS, B.E.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
char a["oddnumber","evennumber"];
printf("\nEnter a number: ");
scanf("%d",&n);
printf("%s",a[n%2]); //when odd, a[1] will print odd number
getch();
}
| Is This Answer Correct ? | 9 Yes | 3 No |
Post New Answer View All Answers
Explain what will the preprocessor do for a program?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
what is the basis for selection of arrays or pointers as data structure in a program
Can you write the algorithm for Queue?
Differentiate between declaring a variable and defining a variable?
Explain null pointer.
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.
What are identifiers and keywords in c?
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
What tq means in chat?
What is the -> in c?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
What is sizeof in c?
what is the function of pragma directive in c?
simple program of graphics and their output display