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
What are the functions to open and close file in c language?
Explain what are global variables and explain how do you declare them?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
What is sizeof array?
What is double pointer in c?
What is the difference between typedef struct and struct?
How main function is called in c?
What is a class c rental property?
What is the 'named constructor idiom'?
What are the differences between new and malloc in C?
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
Why is sizeof () an operator and not a function?
What is the use of #define preprocessor in c?
How can you restore a redirected standard stream?
What does typeof return in c?