what is the other ways to find a logic to print whether a
number is an even or odd wit out using % symbol??????? i
know three different ways to print it. so i need any other
different logic>>>>>
Answers were Sorted based on User's Feedback
Answer / govind279
#include<stdio.h>
main()
{
int x;
printf("Enter an ineteger ");
scanf("%d",&x);
if(x&0x1)
printf("Odd\n");
else
printf("Even\n");
}
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / abdur rab
You can do it without using if even
#include <stdio.h>
int main ( int argc, char* argv[] )
{
int _number;
char _value[2][5]={"EVEN", "ODD"};
printf( "Enter an ineteger :" );
scanf( "%d", &_number );
printf( "\nThe given number is :%s", _value [ x &
0x1 ] );
return ( 0 );
}
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / tirtharaj dash@nist
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,r,i;
scanf("%d",&b);
int temp=b;
for(i=1;i<=b/2;i++)
{
r=temp-2*i;
}
if(r==0)
printf("\neven...");
else
printf("\nodd");
getch();
return 0;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / amit kumar samal
#include<stdio.h>
#include<conio.h>
void main()
{
int newno;
printf("Enter your number: ");
scanf("%d",&newno);
int result=newno/10;
int reminder=newno-result*10;
int value=reminder/2;
if(value==0)
{
printf("%d is an Even number",newno);
}
else
printf("%d is an Odd number",newno);
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / abdur rab
Sorry i forgot to change the variable name. this ud work
#include <stdio.h>
int main ( int argc, char* argv[] )
{
int _number;
char _value[2][5]={"EVEN", "ODD"};
printf( "Enter an ineteger :" );
scanf( "%d", &_number );
printf( "\nThe given number is :%s", _value [
_number &
0x1 ] );
return ( 0 );
}
Is This Answer Correct ? | 0 Yes | 0 No |
Write a program that takes a 5 digit number and calculates 2 power that number and prints it
What are header files in c programming?
What is the process of writing the null pointer?
There is a number and when the last digit is moved to its first position the resultant number will be 50% higher than the original number.Find the number?
write a program to search for an element in a given array. If the array was found then display its position otherwise display appropriate message in c language
Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)
Write a program to print fibonacci series using recursion?
Write a program to print all the prime numbers with in the given range
8 Answers ABC, College School Exams Tests, TCS,
What are structure members?
In C language what is a 'dangling pointer'?
What does 2n 4c mean?
main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }
11 Answers CISOC, CitiGroup, College School Exams Tests,