Problem
Suppose you are given ten paisa on day 1 and on day 2 you are given twice as much. If each day you are given twice as much money as on the previous day, then on day 15, how much money you will receive? Build a C program to find the solution.Total money for day 1 is Rs. 0.20
Total money for day 2 is Rs. 0.40
Total money for day 3 is Rs. 0.80
Total money for day 4 is Rs. 1.60
………….
Solution - Code
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
main()
{
int i;
float x=0.20;
printf("Total money for day 1 = Rs.0.20\n");
for(i=1;i<=15;i++)
{
x = (x*2);
printf("Total money for day %d = %f\n",i,x);
}
system("pause");
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.