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.
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
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; } }
#include<stdio.h> #include<conio.h> void main() { clrscr(); int n, x,y,z; printf("nEnter the number:"); scanf("%d",&n); x=n%10; y=n/10; z=x+y; if(n==3*z) { printf("nnThis is required number ...."); } else printf(""nnEnter Some other number");
Q.2. #include<stdio.h> #include<conio.h> int main() { int i,day,bact; clrscr(); printf("Enter the no. of day and the total no. of bacterian"); scanf("%d %d",&day,&bact); for(i=day;i>1;i--) b=b/2; printf("Number of bacteria present in the 1st day is=%dn",bact); getch(); return 0; }
Q.6. #include<stdio.h> #include<conio.h> int main() { float r; int x; clrscr(); printf("Enter the Rs.n"); scanf("%f",&r); x=r*4/7; printf("If there r equal no. of 25 paise coins, 50 paise coins and one rupee coins, then the no of each coins is %d n",x); getch(); return 0; }
Q.8. #include<stdio.h> #include<conio.h> int main() { int x,y,p,q; clrscr(); printf("Enter the no of eyes and foot in totaln"); scanf("%d %d",&p,&q); x=(q-p)/2; y=(p-2*x)/2; printf("The no of goats in the farm is = %dn",x); printf("The no of ducks in the farm is = %dn",y); getch(); return 0; }
//The equations are //1. 2*(x+y)=p; //2. 4*x + 2*y=q;
#include
using namespace std;
int main()
{
int end=13312;
for(int i=0;i<10;i++)
{
end=end/2;
}
cout<<"The number is :"<
return 0;
}
~
~
Rohan
Jun 18th, 2015
It says find the magic number, so we need to check all possible combinations.
Maximum number is 3*(9+9) = 54. So we can check for all numbers from 0 to 54.
Tricky C Program questions
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.
Questions by ganesan81
Related Answered Questions
Related Open Questions