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 (2264)
 C++ interview questions  C++ Interview Questions (1119)
 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
 
write a program to find the sum of the array elements in c language?   21
A.C func() { pritnf(" in fuction %d",MACRO); } MAIN.c testfunc() { #define MACRO 10 printf("in test function %d", MACRO); } main() { printf("in main %d",MACRO); func(); testfunc(); getch(); } Wipro 2
what is C? Syntel 9
what is the value of b if a=5; b=++a + ++a Infosys 27
write a C code to reverse a string using a recursive function, without swapping or using an extra memory. Motorola 9
for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be printed?????????   7
Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ..a[49][49]). Finally, print out how many zeros and ones in the diagonal. Infosys 3
program to get the remainder and quotant of given two numbers with out using % and / operators? IBM 10
array contains zeros and ones as elements.we need to bring zeros one side and one other side in single parse. ex:a[]={0,0,1,0,1,1,0,0} o/p={0,0,0,0,0,1,1,1} Motorola 11
What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,\0,n*sizeof(char)); } main() { char *g="String"; myalloc(g,20); strcpy(g,"Oldstring"); printf("The string is %s",g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these IBM 3
how to find the sizof of any datatype using bit manipulations   3
How can I access a memory located at certain address? CSC 2
 
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