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 (2253)
 C++ interview questions  C++ Interview Questions (1111)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (646)
Question
Design a program using an array that lists even numbers and
odd numbers separately from the 12 numbers supplied by a user.
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
#include<stdio.h>
#include<conio.h>
void main()
{
int a[12],b[12],c[12],i,j=0,k=0;
clrscr();
printf("Enter 12 numbers\n");
for(i=0;i<12;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<12;i++)
{
if((a[i]%2)==0)
{
b[j]=a[i];
j++;
}
else
{
c[k]=a[i];
k++;
}
}
printf("The even numbers are\n");
for(i=0;i<j;i++)
{
printf("%d\n",b[i]);
}
printf("The odd numbers are\n");
for(i=0;i<k;i++)
{
printf("%d\n",c[i]);
}
getch();
}
 
Is This Answer Correct ?    64 Yes 19 No
Belsia
 
Answer
# 2
main()
{
int a[12],j;
printf("enter 12 numbers");
for(i=0;i<12;i++)
scanf("%d",&a[i]);
printf("even numbers\n");
for(i=0;i<n;i++)
if(a[i]%2==0)
printf("%d ",a[i]);
printf("odd numbers\n");
for(i=0;i<12;i++)
if(a[i]%2)
printf("%d ");
}
printf("%d ",a[i]);
 
Is This Answer Correct ?    11 Yes 13 No
Valli
 
 
 
Answer
# 3
in the above program the last for loop is LOGICALLY WRONG
one...... the last forloop must be changed as...


I WILL COME WITH A ANSWER AS SOON AS POSSIBLE
 
Is This Answer Correct ?    7 Yes 10 No
Vignesh1988i
 
Answer
# 4
in list 12 all can be even or all can be odd so it require
3 array of same size

#include<stdio.h>
void main()
{
int a[12],even[12],odd[12],i,c=0,d=0;
printf("enter 12 numbers");
for(i=0;i<12;i++)
scanf("%d",&a[i]);
for(i=0;i<12;i++)
(n[i]%2==0)?even[c++]=a[i]:odd[d++]=a[i];
printf("seprate list of odd entries");
for(i=0;i<=d;i++)
printf("%d",odd[i]);
printf("seprate list of even entries");
for(i=0;i<=d;i++)
printf("%d",even[i]);
}
 
Is This Answer Correct ?    2 Yes 5 No
Atul Shukla
 
Answer
# 5
#include<stdio.h>
int main()
{
int n,i,j=0,k,count1=0,count2=0;
int a[10],b[10],c[10] ;
printf("Enter value for n\n");
printf("Enter value for array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i] % 2== 0){
count1++;
b[j] = a[i];
j++;
}
else
{
count2++;
c[j] = a[i];
j++;
}
}//End of forloop
j=0;
while(b[j] != '\0')
printf("Even nubers %d\n",b[j]);
printf("No of Even numbers\n");
k =0 ;
while(c[k] != '\0')
printf("Odd nuber %d\n",c[k]);
printf("No of Odd numbers\n");

}
 
Is This Answer Correct ?    6 Yes 11 No
Dally
 
Answer
# 6
/* program to print even nums in even position,odd in odd
position*/
/* Ex: 2 1 3 4 output:2 1 4 3*/
/* work for almost all check it if any wrong*/
#include<stdio.h>
#include<conio.h>

void main()
{
int a[4],j=0,i;
int b[4],e=0,od=1;
clrscr();
for(i=0;i<4;i++)
{
printf("Enter A number : ");
scanf("%d",&a[i]);
}
for(i=0;i<4;i++)
{
if((a[i]%2)==0)
{
j=e;
b[j]=a[i];
e=j+2;
}
else
{
j=od;
b[j]=a[i];
od=od+2;
}
}
for(j=0;j<4;j++)
{
printf("%d\n",b[j]);
}
getch();
return;
}
 
Is This Answer Correct ?    3 Yes 10 No
Prakash.
 
Answer
# 7
A SMALL FLOWER BRACES IS LEFT.......

THE FOLLOWING IS THE RIGHT PROGRAM


#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],*ptr[50],count=0,n,flag=1;
printf("enter the max. elements to be entered :");
scanf("%d",&n);
int k=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]%2!=0)
{
ptr[k]=&a[i];
count++;
k++;
}
else
flag=0;
}
printf("odd numbers :\n");
for(i=0;i<count;i++)
printf("%d\n",*(*(ptr+i)));
if(flag==0)
{
printf("even numbers :\n");
for(i=0;i<n;i++)
{
if(ptr[i]!=&a[i])
printf("%d\n",a[i]);
}
}
getch();
}
 
Is This Answer Correct ?    2 Yes 11 No
Vignesh1988i
 
Answer
# 8
A SMALL IMPLEMENTATION OF POINTERS

#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],*ptr[50],count=0,n,flag=1;
printf("enter the max. elements to be entered :");
scanf("%d",&n);
int k=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]%2!=0)
{
ptr[k]=&a[i];
count++;
k++;
}
else
flag=0;
printf("odd numbers :\n");
for(i=0;i<count;i++)
printf("%d\n",*(*(ptr+i)));
if(flag==0)
{
printf("even numbers :\n");
for(i=0;i<n;i++)
{
if(ptr[i]!=&a[i])
printf("%d\n",a[i]);
}
}
getch();
}


thank you
 
Is This Answer Correct ?    3 Yes 14 No
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what is a non volatile key word in c language?   1
why we shiuld use main keyword in C   5
difference between spiral and waterfall model   1
When is an interface "good"?   1
WHAT IS HIGH LEVEL LANGUAGE?   2
how can i get the output 54321 4321 321 21 1 in c programming........???? pls help...... Infosys 8
write a c program to find biggest of 3 number without relational operator? Wipro 12
what is the diff b/w static and non static variables in C. Give some examples plz. Wipro 3
c program to subtract between two numbers without using '-' sign and subtract function.   2
When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it? Aloha-Technology 2
write the program for prime numbers? TCS 73
Define a structure to store the record of library. The record must consist of at least following fields: Title, Author, Edition, Price, Publisher, and Category. -Define functions authorSearch ( ), TitleSearch ( ) and CategorySearch ( ) to search a book with respect to author, title and category. [There can be more than one book, written by one author, in one category]   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