#include<stdio.h>
int main()
{
float p, r, t;
char ch = 'y';
do
{
printf("Enter principal: ");
scanf("%f", &p);
printf("Enter rate: ");
scanf("%f", &r);
printf("Enter t: ");
scanf("%f", &t);
printf("SI = %f", (p *r * t)/100 );
printf("\nCalculate SI one more time ? ('Y' for Yes, 'n' for no ) : ");
ch = getchar();
}while(ch == 'y');
return 0;
}
Output:
Enter principal: 1334
Enter rate: 4
Enter t: 2
SI = 106.720000
Calculate SI one more time ? ('Y' for Yes, 'n' for no ) :
Process returned 0 (0x0) execution time : 5.359 s
Press any key to continue.
As you can see i am unable to calculate SI second time ?? What is the problem ?
I even tried replacing getchar() by scanf() but it is still not working