ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
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>>>>>
 Question Submitted By :: Vignesh1988i
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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>>>>>
Answer
# 1
#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 ?    3 Yes 0 No
Govind279
 
  Re: 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>>>>>
Answer
# 2
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 ?    1 Yes 0 No
Abdur Rab
 
 
 
  Re: 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>>>>>
Answer
# 3
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
Abdur Rab
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
How the processor registers can be used in C ? HP4
why we shiuld use main keyword in C  5
What is a far pointer?What is the utility?  2
void main() {int a[5],i,b=16; for(i=0;i<5;i++) a[i]=2*i; f(a,5,b); for(i=0;i<5;i++) printf("\n %d",a[i]); printf("\n %d",b); } f(int *x,int n,int y) { int i; for(i=0;i<n;i++) *(x+i)+=2; y=y+2; }wat r the errors in the prg.and improvise the prg to get o/p.?  2
to find the program of matrix multiplication using arrays  2
write the program for prime numbers? TCS10
how does printf function work  1
How do I initialize a pointer to a function?  2
#define f(x) main() { printf("\n%d",f(2+2)); }  3
what is the difference between c and java?  1
Which of the following sorts is quickest when sorting the following set: 1 2 3 5 4 1) Quick Sort 2) Bubble Sort 3) Merge Sort  5
what will be the output: main(){char ch;int a=10;printf("%d",ch);} Wipro29
write a program to generate 1st n fibonacci prime number  5
write a program for odd numbers?  6
34.what are bitwise shift operators? 35.what are bit fields? What is the use of bit fields in a structure declaration? 36.what is the size of an integer variable? 37.what are the files which are automatically opened when a c file is executed? 38.what is the little endian and big endian? 39.what is the use of fflush() function? 40.what is the difference between exit() and _exit() functions? 41.where does malloc() function get the memory? 42.what is the difference between malloc() and calloc() function? 43.what is the difference between postfix and prefix unary increment operators?  2
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? Hughes5
wats the diference btwen constant pointer and pointer to a constant.pls give examples.  6
related to rdbms query .  1
whether itis a structured language? Microsoft1
Study the code: void show() main() { show(); } void show (char *s) { printf("%sn",s); } What will happen if it is compiled & run on an ANSI C Compiler? A)It will compile & nothing will be printed when it is executed B)it will compile but not link C)the compiler will generate an error D)the compiler will generate a warning Accenture4
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com