ALLInterview.com :: Home Page            
 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                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2265)
 C++ interview questions  C++ Interview Questions (1123)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (648)
Question
To find whether a number is even or odd without using any
conditional operator??
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
/* By Mohd Adnan MCA(2007-10) IMS Ghaziabad */
/* by using bit wise operator*/
#include<stdio.h>
#include<conio.h>
void main()
{
int num;
printf("Enter any number:");
scanf("%d",%num);
(num&1)&&printf("Odd Number");
((num&1)==0)&&printf("Even Number");
getch();
}
 
Is This Answer Correct ?    32 Yes 11 No
Mohd Adnan
 
Answer
# 2
import java.io.*;

public class even {
public static void main(String arg[])throws IOException
{
String a[]={"even","odd"};
int p;
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter a number to find:");
int n=Integer.parseInt(br.readLine());
p=n%2;
System.out.println("The Number is :"+a[p]);


}
}
 
Is This Answer Correct ?    20 Yes 6 No
Amala V
 
 
 
Answer
# 3
main ()
{
int num;
if ( num & 1 )
printf ("num is odd number\n");
else
printf ("num is even number\n");
}
 
Is This Answer Correct ?    17 Yes 8 No
Naveen
 
Answer
# 4
/*PROGRAM BY JAI GOMATHI.NS, B.E.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
char a["oddnumber","evennumber"];
printf("\nEnter a number: ");
scanf("%d",&n);
printf("%s",a[n%2]); //when odd, a[1] will print odd number
getch();
}
 
Is This Answer Correct ?    7 Yes 1 No
Jai Gomathi
 
Answer
# 5
void main()
{
int n;
clrscr();
printf("enter any no.");;
scanf("%d",&n);
if(n%2==0)/*remainder after division by 2*/
printf("\nthe no. is even");
else
printf("\nthe no. is odd");
}
getch();
}
 
Is This Answer Correct ?    9 Yes 8 No
Azad Sable,chiplun.
 
Answer
# 6
friends

u are using if condition in program.. u should not use
that.because the question is without any condition. if is
also a condition ok. so try to find without if .
 
Is This Answer Correct ?    4 Yes 3 No
Amala V
 
Answer
# 7
/* ZAIN JATOI AND UMAIR JATOI */
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n;
printf("Enter any number:");
scanf("%d",&n);
if(n&1)
printf("%d is Odd number",n);
else
printf("%d is even number",n);
getch();
}
 
Is This Answer Correct ?    1 Yes 0 No
Umair Jatoi && Zain Ja
 
Answer
# 8
int main()
{
int a[2][5]={"Even","Odd"};
int n;
printf("Enter Integet No:");
scanf("%d",&n);
printf("\nResult:%d",a[n%2]);
}
 
Is This Answer Correct ?    0 Yes 0 No
Rudrakshala Leela Phani Kumar
 
Answer
# 9
main()
{
int num;
clrscr();
printf("enter the number");
scanf("%d",&num);
(num%2==0)?printf("even num"):printf("odd num");
}
 
Is This Answer Correct ?    13 Yes 15 No
Mukul Garg
 
Answer
# 10
main()
{
int n;
printf("enter the number\n");
scanf("%d",&n);
if(n%2==0){
printf("number is even");}
else{
printf("number is odd");
}
}
or
if(n&1==0)
printf("even number");
else
printf(odd number");
 
Is This Answer Correct ?    31 Yes 38 No
Kala
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What is the memory allocated by the following definition ? int (*x)[10]; ADITI 4
Can we include one C program into another C program if yes how? Infosys 7
how to print this sereis 2 4 3 6 5..........?   2
what is the output of the following program? #include<stdio.h> void main() { int x=4,y=3,z; z=x-- -y; printf("\n%d %d %d",x,y,z); }   14
If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit. Google 11
You have an array of n integers, randomly ordered with value 1 to n-1.The array is such that there is only one and one value occurred twice. How will you find this number?   1
implement NAND gate logic in C code without using any bitwise operatior. Alcatel 4
what are the static variables HCL 8
whether itis a structured language? Microsoft 1
what is the self-referential structure?   1
different between overloading and overriding   3
main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } what is the output? Ramco 9
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com