GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 193 of 453    Print  

The questions are as follows:


1. Write a 'c' program to read the age of 100 persons and count the number
of persons in the age group 50 to 60.use for loop and continue statements.(10
marks)

2. Write a program to read a positive integer and print its binary
equivalent.(10 marks)

3. Given two one dimensional arrays a and b which are sorted in ascending order.
write a program to merge them into a single sorted array ,c that contains every
item from arrays a and b, in ascending order.(10 marks)

4. Write a function in c that would traverse a linear singly linked list in
reverse and write out the contents in reverse order.(10 marks)

5. Write a program to read a set of integers and to separate all odd and even
numbers. write all even numbers in ascending order.(10 marks)

6. Write a program to read a real number x and find the even number nearest to
x.(10 marks)

7. Write a program to multiply two matrices of order m*n and n*p
respectively.(10 marks)

8. Write a program in'c' to implement k-map simplification technique.(10
marks)


  
Total Answers and Comments: 11 Last Update: May 07, 2008     Asked by: Arka chakraborty 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: sri harsha
 
JUST PUT A COUNTER TO COUNT THE MEMBERS WITH AGE BETWEEN 50 AND 60.initialise c=0.for(i=0;i<100;i++){ scanf("%d",&a[i]); if((a[i]>50)&&(a[i]<60)){ c++;}}

Above answer was rated as good by the following members:
youvapankaj2004
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
March 09, 2006 09:42:08   #1  
sri harsha Member Since: February 2006   Contribution: 4    

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...
JUST PUT A COUNTER TO COUNT THE MEMBERS WITH AGE BETWEEN 50 AND 60.initialise c 0.for(i 0;i<100;i++){ scanf( d &a[i]); if((a[i]>50)&&(a[i]<60)){ c++;}}
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
March 10, 2006 23:16:43   #2  
novicecoda Member Since: March 2006   Contribution: 3    

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...
please post answers in the forum too so that everyone could read them .Couuld i have the solution to the 2nd question
 
Is this answer useful? Yes | No
March 18, 2006 20:19:42   #3  
Casanova Member Since: March 2006   Contribution: 3    

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...
for the 2nd// assume a stackwhile (no) { push (no 2); no/ 2;}while (stack not empty) print pop ()
 
Is this answer useful? Yes | No
March 27, 2006 23:59:16   #4  
venkatesh Member Since: November 2005   Contribution: 19    

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...

for 3 rd question

let us take source arrays A & B and destinaton is C

take three index variables I J K respectively for each array

take n and m are the size of arrays

while(i< n &&j< m)

{

if (a[i]<b[j]) c[k++] a[i++]

else c[k++] b[j++]

}

while(i< n) c[k++] a[i++];

while(j< m) c[k++] b[j++];

then c array contains sorted data of A and B


 
Is this answer useful? Yes | No
March 28, 2006 22:55:41   #5  
venkatesh Member Since: November 2005   Contribution: 19    

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...

for first question no need to take array

count 0;

for(int i 0;i<100;i++)

{

scanf( d &x)

if(x> 50 && x< 60) count++;

}


 
Is this answer useful? Yes | No
April 20, 2006 22:41:54   #6  
shibaji.paul Member Since: April 2006   Contribution: 5    

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...

I am having a recursive solution to the 2nd problem though one can find a non-recursive solution thru the implementation of stack.

void printBinary(int n)
{
if (n>0)
{
printBinary(n/2);
printf( c 01 [n 2]);
}
else
{
printf( \n );
}
}


 
Is this answer useful? Yes | No
April 20, 2006 22:47:00   #7  
shibaji.paul Member Since: April 2006   Contribution: 5    

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...

Solution of q4 could also be made with recursion.

void traverseInReverse(Node *hp)
{
if (hp! NULL)
{
traverseInReverse(hp->next);
printf( \n d hp->data);
}
else
{
return;
}
}

Three cheers for recursion. (sorry for those who always wants efficiency rather than some fun coding)


 
Is this answer useful? Yes | No
September 28, 2006 01:17:03   #8  
swetha76 Member Since: September 2006   Contribution: 2    

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...

The answer to the first question

#include<stdio.h>
main()
{
int age[5] i 0 count 0;
for(i 0;i<5;i++)
{
printf( Enter the age of the d person i+1);
scanf( d &age[i]);
}
for(i 0;i<5;i++)
{
if((age[i]> 50)&&(age[i]< 60))
count++;
}
printf( The no of the people between the age group 50 and 60 is d count);
}


 
Is this answer useful? Yes | No
November 13, 2006 13:49:32   #9  
shiv reddy        

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...

void agecheck(int a[])

{

int count 0;

for(int i 0;i<100;i++)

{

if(a[i]>50 ||a[i]< 60)

{

}count++;

}

else continue;

}

}


 
Is this answer useful? Yes | No
March 20, 2007 08:16:43   #10  
venkat_ceg        

RE: THE QUESTIONS ARE AS FOLLOWS:1.WRITE A...

void main()
{
int i a[15] n;
clrscr();
printf("Enter a no:n");
scanf(" d" &n);
for(i 0;i<15;i++ n>> 1)//Vary de bit size accordingly
a[i] n&1;
for(i 15;i> 0;i--)
printf(" d" a[i]);
getch();
}



 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape