Simple intrest
Title
Question
#include
i<stdio.h>nt main()</stdio.h>
<stdio.h> {</stdio.h>
<stdio.h> float principle, time, rate, SI; </stdio.h>
<stdio.h> printf("Enter principle (amount): "); </stdio.h>
<stdio.h> scanf("%f", &principle); </stdio.h>
<stdio.h> printf("Enter time: "); </stdio.h>
<stdio.h> scanf("%f", &time); </stdio.h>
<stdio.h> printf("Enter rate: ");</stdio.h>
<stdio.h> scanf("%f", &rate); </stdio.h>
<stdio.h> SI = (principle * time * rate) / 100; </stdio.h>
<stdio.h> printf("Simple Interest = %f", SI); </stdio.h>
<stdio.h> return 0; </stdio.h>
<stdio.h> }</stdio.h>
<stdio.h>
</stdio.h>
</stdio.h>
<stdio.h>
</stdio.h>
</stdio.h>
<stdio.h>
</stdio.h>
</stdio.h>
Gokulapriya
Ece department irtt
C-and-Cpp Tokens 06-07 min 40-50 sec
Answers:
something wrong in your editor. You are getting each and every line stdio.h. Refer the following C program, it is working:
#include<stdio.h>
int main()
{
<span style="white-space:pre"> </span>float principle, time, rate, SI;
<span style="white-space:pre"> </span>printf("Enter principle (amount): ");
<span style="white-space:pre"> </span>scanf("%f", &principle);
<span style="white-space:pre"> </span>printf("Enter time: ");
<span style="white-space:pre"> </span>scanf("%f", &time);
<span style="white-space:pre"> </span>printf("Enter rate: ");
<span style="white-space:pre"> </span>scanf("%f", &rate);
<span style="white-space:pre"> </span>SI = (principle * time * rate) / 100;
<span style="white-space:pre"> </span>printf("Simple Interest = %f", SI);
<span style="white-space:pre"> </span>return 0;
}
Result
C:\cygwin64\bin>gcc -o Simple_Interest Simple_Interest.c
C:\cygwin64\bin>Simple_Interest
Enter principle (amount): 20000
Enter time: 60
Enter rate: 12
Simple Interest = 144000.000000
#include <iostream>
using namespace std;
float solve( int P, int T, float R ) {
float si; si = (P * T * R) / 100;
return si;
} int main()
{ int P = 10000;
int T = 7; float R = 6.25;
cout << "Simple interest for 10,000 with ROI 6.25\% for 7 years is: ";
float result;
result = solve( P, T, R );
cout << result << endl;
cout << "Total amount is: " << P + result;
return 0;
}
Login to add comment