forked from sumanchaurasiya/C-Solution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_interest_programm.c
72 lines (70 loc) · 2.36 KB
/
simple_interest_programm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* Program name is simple interest */
// ---------Formula-----------//
// p=100*i/r*t
// r=100*i/p*t
// t=100*i/p*r
// i=p*r*t/100
//----------Programm in below------------//
#include<stdio.h>
int main()
{
int p,r,t,i,num;
printf("--------------what are you find?--------------");
printf("\n1.Principal."); // p=100*i/r*t
printf("\n2.Percentage."); // r=100*i/p*t
printf("\n3.Time."); // t=100*i/p*r
printf("\n4.Amount.\n"); // i=p*r*t/100
scanf("%d",&num);
switch(num) // use case concept for choose option.
{
case 1: // p=100*i/r*t
{
printf("Enter the amount :");
scanf("%d",&i);
printf("Enter the percentage :");
scanf("%d",&r);
printf("Enter the time :");
scanf("%d",&t);
p=100*i/r*t;
printf("The principal is :%d",p);
break;
}
case 2: // r=100*i/p*t
{
printf("Enter the amount :");
scanf("%d",&i);
printf("Enter the principal :");
scanf("%d",&p);
printf("Enter the time :");
scanf("%d",&t);
r=100*i/p*t;
printf("The percentage is :%d",r);
break;
}
case 3: // t=100*i/p*r
{
printf("Enter the amount :");
scanf("%d",&i);
printf("Enter the principal :");
scanf("%d",&p);
printf("Enter the percentage :");
scanf("%d",&r);
t=100*i/p*r;
printf("The time is :%d",t);
break;
}
case 4: // i=p*r*t/100
{
printf("Enter the principal :");
scanf("%d",&p);
printf("Enter the percentage :");
scanf("%d",&r);
printf("Enter the time :");
scanf("%d",&t);
float i=p*t*r/100;
printf("The amount is :%f",i);
break;
}
}
return 0;
}