February 4, 2011

C Program Calculate Simple Interest for 3 sets of p, n & r

Using while loop


/*C Program Calculate Simple Interest for 3 sets of p, n & r
p, n & r represent principle, no. of years & rate of interest*/
#include<stdio.h>
#include<conio.h>
void main()
{
int p,n,count=1;
float r,si;
clrscr();
while(count<=3)
{
printf("Enter value for p,n & r\n\n");
scanf("%d%d%f",&p,&n,&r);
si=(p*n*r)/100;
printf("\nSimple Interest =%f",si);
count++;
}
getch();
}

------------------------------------------------------------------------------------------------------------
Using for loop

/*C Program Calculate Simple Interest for 3 sets of p, n & r
p, n & r represent principle, no. of years & rate of interest*/
#include<stdio.h>
#include<conio.h>
void main()
{
int p,n,count;
float r,si;
clrscr();
for(count=1;count<=3;count++)
{
printf("\n\nEnter the value for p, n & r\n\n");
scanf("%d%d%f",&p,&n,&r);
si=p*n*r/100;
printf("Simple Interest=%f",si);
}
getch();
}

Hope you liked my posts, give comments if you have any doubts.. :)

Related Posts :



Categories: ,

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails