Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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 a pointer a kind of array?

0 Answers  


which types of data structure will i use to convert infix to post fix???

5 Answers   IIT,


What is #line used for?

0 Answers  


Write a function that will take in a phone number and output all possible alphabetical combinations

0 Answers   Motorola,


when to use : in c program?

2 Answers  


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

0 Answers  


i have a written test in tomorrow

1 Answers   NNN, Value Labs,


what is a stack

6 Answers  


What is an lvalue and an rvalue?

1 Answers  


what is the difference between arrays and linked list

26 Answers   MAHINDRA, Tech Mahindra, Wipro,


where are auto variables stored? What are the characteristics of an auto variable?

0 Answers  


typedef struct { int i:8; char c:9; float f:20; }st_temp; int getdata(st_temp *stptr) { stptr->i = 99; return stptr->i; } main() { st_temp local; int i; local.c = 'v'; local.i = 9; local.f = 23.65; printf(" %d %c %f",local.i,local.c,local.f); i = getdata(&local); printf("\n %d",i); getch(); } why there there is an error during compiling the above program?

1 Answers  


Categories