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 (2248)
 C++ interview questions  C++ Interview Questions (1106)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (644)
Question
To find whether a number is even or odd without using any
conditional operator??
 Question Submitted By :: Rajesh
I also faced this Question!!     Rank Answer Posted By  
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 1
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 ?    30 Yes 35 No
Kala
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 2
void main()
{
int n;
printf("enter n:");
scanf("%d",&n);
if(n%2==0)
printf( "even");
else
printf("odd");
}
 
Is This Answer Correct ?    14 Yes 32 No
Sahithya
 
 
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 3
/* 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 ?    31 Yes 10 No
Mohd Adnan
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 4
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
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 5
main()
{
int num;
clrscr();
printf("enter the number");
scanf("%d",&num);
(num%2==0)?printf("even num"):printf("odd num");
}
 
Is This Answer Correct ?    12 Yes 14 No
Mukul Garg
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 6
main ()
{
int num;
if ( num & 1 )
printf ("num is odd number\n");
else
printf ("num is even number\n");
}
 
Is This Answer Correct ?    15 Yes 8 No
Naveen
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 7
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 ?    8 Yes 8 No
Azad Sable,chiplun.
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 8
/*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 ?    5 Yes 1 No
Jai Gomathi
 
  Re: To find whether a number is even or odd without using any conditional operator??
Answer
# 9
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 1 No
Amala V
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
20. main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); } Answer:??????   2
Explain demand paging.   1
write a program for even numbers? TCS 19
consagous technology placement paper Consagous 3
can you change name of main()?how? Siemens 3
What is Generic pointer? What is the purpose of Generic pointer? Where it is used?   3
compute the nth mumber in the fibonacci sequence? TCS 10
write a program to swap two variables a=5 , b= 10 without using third variable   5
what is ANSI and ISO HCL 7
suppose there are five integers write a program to find larger among them without using if- else   2
Write a program in C to reverse a number by recursive function?   1
in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ? NetApp 1
 
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