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



what is the other ways to find a logic to print whether a number is an even or odd wit out using % ..

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

what is the other ways to find a logic to print whether a number is an even or odd wit out using % ..

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

what is the other ways to find a logic to print whether a number is an even or odd wit out using % ..

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

what is the other ways to find a logic to print whether a number is an even or odd wit out using % ..

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

what is the other ways to find a logic to print whether a number is an even or odd wit out using % ..

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

Post New Answer

More C Interview Questions

Is int a keyword in c?

0 Answers  


What is the difference between char array and char pointer?

0 Answers  


wat is the output #define VOLEDEMORT _who_must_not_be_named int main() { printf("VOLEDEMORT"); }

2 Answers  


What is the difference between int main and void main?

0 Answers  


what is difference between procedural language and functional language ?

4 Answers   Wipro,






What does the file stdio.h contain?

0 Answers  


If "AaBbCc" is passed to the char char x(*a) { a[0]?x(a+1):1; printf("%c",a[0]); return 1; } what will be the output?

6 Answers   Hughes,


What will be the outcome of the following conditional statement if the value of variable s is 10?

0 Answers  


Difference between for loop and while loop?

1 Answers  


Explain a file operation in C with an example.

0 Answers   Amdocs,


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

0 Answers   Persistent,


Go through the following code sinippet char a[20]; a="Hello Orcale Test"; will this compile?

4 Answers   Oracle,


Categories