GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Accenture  >  Technical
Go To First  |  Previous Question  |  Next Question 
 Technical  |  Question 30 of 31    Print  
Tricky C Program questions
1)Write a C program to find a peculiar two digit number which is three times the sum of its digits.

2) Bacteria are known to multiply very rapidly. If a certain container contains just one bacterium on the first day and there are twice as many on the next day. In this manner the number of bacteria in the container doubles itself everyday. Assuming that the container would be full on the 10th day with 13,312 bacteria, find the number of bacteria that was initially in the container on the first day.

3) Calculate the factorial of a number recursively. From that calculate the value of COS(X) = 1 - X2/2! + X4 /4! - X6/ 6! +…….

4) A number of “Cats” got together and decided to kill between them 999919 mice. Every cat killed equal number of “mice”. Write a program to find number of cats.

5) Consider the following number 45*45=2025; 20+25=45.Write a program to generate number between 32 and 99 that satisfies the above property.

6) Rita has a money pouch containing Rs.700. There are equal number of 25 paise coins, 50 paise and one rupee coins. Write a C program to find how many of each are there?

7) Calculate the factorial of a number recursively and from that calculate the value of ex=1+ (X1/1!) + (X2 /2!) + (X3/3!) + ……….

8) There are some goats and ducks in a farm. There are 60 eyes and 86 foot in total. Write a program to find number of goats and ducks in the farm.

9) Write a C program to find a three digit number which is greater than the aggregate of its third, tenth and the twelfth parts by 58.

10) Write a C program to find a two digit number, the second digit of which is smaller than its first digit by 4, and if the number was divided by the digit’s sum, the quotient would be 7.



  
Total Answers and Comments: 9 Last Update: October 23, 2009     Asked by: ganesan81 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: milan.kadivar
 

#include <stdio.h>
#include <conio.h>
void main()
{
 int i,x,y;
 clrscr();
 for(i=10;i<100;i++)
  {
    x=i/10;
    y=i%10;
    if(((x+y)*3)==i)
         printf("Peculiar Num is : %d",i);
  }
  getch();
}



Above answer was rated as good by the following members:
sudhansupatra
May 27, 2008 09:46:41   #1  
BECKONLAND2004 Member Since: May 2008   Contribution: 1    

RE: Tricky C Program questions

Write a C-COde to blink the character


 
Is this answer useful? Yes | No
October 31, 2008 13:32:05   #2  
ravikth Member Since: October 2008   Contribution: 4    

RE: Tricky C Program questions

Step1: We have to check the condition xy 3(x+y) -> xy/3 x+y


The above statements unveil two essential points to write efficient program

1. x and y must be int value not a real (float) value. so the xy will be
divisible by 3.

2. Maximum value of 3(x+y) is 54 if xy equals to 99 (max value of two digit).

so the xy will be less than 54.


Conclusion: we can get the result by checking the numbers which are divisible
by 3 and less than 54 instead of checking all the numbers.

Ans: 27


 
Is this answer useful? Yes | No
February 02, 2009 11:00:31   #3  
shreekanthss Member Since: February 2009   Contribution: 9    

RE: Tricky C Program questions
1 #include<stdio.h>
#include<math.h>
main()
{
int x y r m;
printf("enter a numbern");
scanf(" d" &x);
y x 10;
x x/10;
r x+y;
m 3*r;
printf(" d" m);
getch();
}

 
Is this answer useful? Yes | No
June 16, 2009 14:07:23   #4  
RamLaw Member Since: August 2008   Contribution: 1    

RE: Tricky C Program questions

Answer for Q:5

#include<stdio.h>
int main(){
int i 32 n 99 sq val1 val2 val3;

while(i < n){
sq i * i;
val1 sq/100;
val2 sq 100;

val3 val1 + val2;

if(val3 i){
printf(" d satisfy propertyn" i);
}

i++;
}
return 0;
}


 
Is this answer useful? Yes | No
June 16, 2009 23:39:14   #5  
milan.kadivar Member Since: February 2009   Contribution: 4    

RE: Tricky C Program questions

#include <stdio.h>
#include <conio.h>
void main()
{
int i x y;
clrscr();
for(i 10;i<100;i++)
{
x i/10;
y i 10;
if(((x+y)*3) i)
printf("Peculiar Num is : d" i);
}
getch();
}


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 26, 2009 11:27:00   #6  
jothejo2 Member Since: June 2009   Contribution: 1    

RE: Tricky C Program questions(1)
Q1.
This is what i've done but dere are still some bugs will fix them later
But this is the whole idea.

#include<stdio.h>

int main()
{
for (i 10;i< 99;i++)
{
j i;
//to do the splitting of the two digit value and find the sum of its digits
while(j ! 0)
{ x j 10;
y y +x;
j j/10;
}
// Because of the relation x +y xy/3
c i/3;
if (c y)
printf("Perculia vlue: d" i);
//break;
}
}

 
Is this answer useful? Yes | No
August 06, 2009 05:50:21   #7  
ranjini.np Member Since: August 2009   Contribution: 1    

RE: Tricky C Program questions- Write a C program to find a peculiar two digit number which is three times the sum of its digits
/* Q1: Write a C program to find a peculiar two digit number which is three times the sum of its digits.*/


#include <stdio.h>
int main()
{
char num;
char second_pos first_pos total;
for(num 10; num < 100; num++)
{
second_pos num / 10;
first_pos num 10 ;
total second_pos + first_pos;

printf("total d n" total);
printf(" d n" (total * 3 ));

if(num (3 * total))
{
printf(" d is the answern" num);
return 0;
}

}
return 0;
}

 
Is this answer useful? Yes | No
October 13, 2009 10:49:13   #8  
npoojasjce Member Since: October 2009   Contribution: 1    

RE: Tricky C Program questions
#include<stdio.h>
void main()
{
int i a b sum;
for(i 10;i<100;i++)
{
a i/10;
b i 10;
sum a+b;
if(b (a-4) && (i/sum) 7)
printf(" dn" i);
}
}

 
Is this answer useful? Yes | No
October 23, 2009 04:31:47   #9  
meenu1992 Member Since: October 2009   Contribution: 2    

RE: Tricky C Program questions
5) Consider the following number 45*45 2025; 20+25 45.Write a program to generate number between 32 and 99 that satisfies the above property.

#include<stdio.h>
#include<conio.h>
void main()
{int i n a b;
for(i 32;i< 99;i++)
{n i*i;
a n 100;
n n100;
b a+n;
{if(b i)
printf(" dt" b);
}
}
getch();
}

 
Is this answer useful? Yes | No


 
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