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

How can I find the day of the week given the date?

0 Answers  


What is encapsulation?

2 Answers  


How can I copy just a portion of a string?

0 Answers  


What is wrong with this code such that it doesnt produce the input reversed? #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char Space = ' '; char LineOfText; float count; LineOfText = getchar(); while ((LineOfText = getchar()) != '/n'); { count = strlen(LineOfText) - 1; while (count >= 0) { putchar(LineOfText[count]); count--; } } getchar(); return 0; }

2 Answers  


implement NAND gate logic in C code without using any bitwise operatior.

4 Answers   Alcatel,






What is memory leak in c?

0 Answers  


Why static is used in c?

0 Answers  


write a c program that prints all multiples of 3between 1 and 50.

5 Answers  


Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.

0 Answers  


1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 generate this output using for loop

2 Answers  


c program to arrange digits in a no in ascending and descending order

1 Answers  


int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation.

15 Answers   Global Edge,


Categories