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 (2266)
 C++ interview questions  C++ Interview Questions (1121)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (652)
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 12 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 y value of the code if input x=10 y=5; if (x==10) else if(x==9) elae y=8; a.9 b.8 c.6 d.7 TCS 3
what is the meaning of java that is (J A V A) full form of JAVA HCL 34
how to copy a string without using c function   5
program to find the roots of a quardratic equation   1
write a programe returns the number of times the character appears in the string   2
The variables are int sum=10,SuM=20; these are same or different?   3
what is c programing Wipro 11
what is the difference between while and do while?   2
what is the output on the screen? int n; n=printf("my name is %d",printf("kiran %d",printf("kumar"))); printf("\n %d \n",n); TCS 4
4.weight conversion: Write a program that will read weight in pounds and convert it into grams.print both the original weight and the converted value.There are 454 grams in a pound.design and carry out a test plan for this program. Wipro 1
What is the difference between File pointer and Internal Charecter Pointer? TATA 2
write a program to find out number of on bits in a number? Huawei 17
 
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