Friday, September 5, 2014

how much money will you receive on day 15 if you are given 0.20 paisa's on 1st day and double on each day


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");
}

Sample Output

calculate amount for day 15


No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact