write a program to calculate percentage in c
Answers
Hello !!
I make this algorithm in C language for you calculate porcentage.
______________________
#include <stdio.h>
float main()
{
float R,number,porcentage;
printf("number(example:30,40,50...): ");
scanf("%f",&number);
printf("porcentage(example:60 percent): ");
scanf("%f",&porcentage);
R = (number * porcentage)/100;
printf("Final result: %f",R);
return 0;
}
_____________________
[See the example (15% of 46) in the compiler in the image].
I hope I have collaborated!
Answer:
#include<iostream.h>
#include<conio.h>
voud main()
{
clrscr();
float a,b, per1,per2,total;
cout<<"\nEnter first number";
cin>>a;
cout<<"\nEnter second number ";
cin>>b;
total=a+b;
per1=(a*100)/total;
per2=(b*100)/total;
cout<<"\nPercentage of"<<a<<" is "<<per1;
cout<<"\nPercentage of"<<b<<"is"<<per2;
getch();
}