Code: Select all
#include<stdio.h>
float n,p,ps,s;
int main()
{
printf("Enter percentage number for all operations: \n%% ");
scanf("%f",&p);
printf("Enter net value, press Ctrl-c to terminate: \n");
for( ; ; ) {
printf("> ");
scanf("%f",&n);
ps = (n * p)/100;
s = n+ps;
printf("%.2f + %.2f = %.2f\n", n, ps, s);
}
return 0;
}
Code: Select all
#include<stdio.h>
float n,p,ps,s;
int main()
{
printf("Enter percentage number to substract for all operations: \n%% ");
scanf("%f",&p);
printf("Enter total gross amount, press Ctrl-c to terminate: \n");
for( ; ; ) {
printf("> ");
scanf("%f",&n);
ps = (n * p)/(100 + p);
s = n-ps;
printf("%.2f - %.2f = %.2f\n", n, ps, s);
}
return 0;
}