Search This Blog

Friday, October 7, 2011

A principal p after n years rate of intrest i amounts to A=p(1+i)n. Write a program to read the principal and rate of intrest and calculate After 1,2,3,4,5,6 years

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  #include<math.h>
   4:  void main()
   5:  {
   6:  int p,n=1;
   7:  float a,i,power;
   8:  printf("\nEnter the principal: ");
   9:  scanf("%d",&p);
  10:  printf("\nEnter the interest: ");
  11:  scanf("%f",&i);
  12:  do
  13:  {
  14:  a=p*pow(1+i,n);
  15:  printf("\nAmount For %d year= %.3f\n",n,a);
  16:  n++;
  17:  }while(n<=5);
  18:  getch();
  19:  }

No comments:

Post a Comment