write a c program to print a given number as odd or even
without using loop statements,(no if ,while etc)
Answers were Sorted based on User's Feedback
#include<stdio.h>
#include<conio.h>
void main()
{
int m;
printf("0 - odd number \t 1 - even number\n");
printf("enter the number :");
scanf("%d",&m);
printf(" %d ",m&1);
getch();
}
thank u
Is This Answer Correct ? | 43 Yes | 27 No |
Answer / avinash kumar
#include<stdio.h>
main()
{
int a;
clrscr();
printf("enter a number:");
scanf("%d",&a);
if(a%2=0)
printf("even");
else
printf("odd")
getch();
}
Is This Answer Correct ? | 25 Yes | 22 No |
Answer / p.thirugnanavel
#include<stdio.h>
#include<conio.h>
void main()
{
int no,ch;
clrscr();
printf("enter the number :");
scanf("%d",&no);
ch=(no%2==0) ? (1) : (2);
switch(ch)
{
case 1:
printf("The number %d is even",no);
break;
case 2:
printf("The number %d is odd",no);
break;
}
getch();
}
Is This Answer Correct ? | 7 Yes | 5 No |
Answer / dheerendra
logic
main()
{
int a;
(a%2==0)?printf("even"):printf("odd")
}
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / manojkumar
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the number :");
scanf("%d",&a);
b=a%2;
switch(b)
{
case 1:
printf("The number %d is even",no);
break;
case 2:
printf("The number %d is odd",no);
break;
}
getch();
}
Is This Answer Correct ? | 3 Yes | 4 No |
Answer / bhabesh rai
#include<stdio.h>
main()
{
int n;
printf("Enter an integer:\n");
scanf("%d", &n);
switch((n%2 == 0) ? (1) : (2))
{
case 1:
printf("EVEN\n", n);
break;
case 2:
printf("ODD\n", n);
break;
}
}
Is This Answer Correct ? | 2 Yes | 3 No |
sorry , just change printf() as.... printf("0 - even number \t 1 - odd number \n ");
thank u
Is This Answer Correct ? | 12 Yes | 19 No |
Answer / dr:rahul
#include<stdio.h>
#include<conio.h>
void main()
{
int rahul;
printf("0 - odd number \t 1 - even number\n");
printf("enter the number :");
scanf("%d",&rahul);
printf(" %d ",rahul&1);
getch();
}
Is This Answer Correct ? | 4 Yes | 14 No |
write a programme to enter some number and find which number is maximum and which number is minimum from enterd numbers.
write a program that prints a pascal triangle based on the user input(like how many stages) in an efficient time and optimized code?
Design a program using an array that lists even numbers and odd numbers separately from the 12 numbers supplied by a user.
Is it possible to create recycle bin in mobiles?
what is the format specifier for printing a pointer value?
Sir i need notes for structure,functions,pointers in c language can you help me please
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }
11 Answers HCL, Vector, Vector India, Vector Solutions, Wipro,
What is the difference between void main and main in c?
what does ‘Bus Error’ mean?
What are operators in c?
write a program of bubble sort using pointer?