I have coded with program for my college assignment, but it looks like there is something wrong with my percentage formula. It always shows percentage as "0".
#include <iostream>
usingnamespace std;
int main()
{
int a, b, c, d, p;
cout<<"Enter first test score: ";
cin>>a;
cout<<"Enter second test score: ";
cin>>b;
cout<<"Enter third test score: ";
cin>>c;
while (a>-1 && b>-1 && c>-1)
{ d=((a+b+c)/3);
cout<<"Average score: "<<d<<endl;
p=(((d)/(a+b+c))*(100));
cout<<"Percentage: "<<p<<endl;
if (p>80)
{
cout<<"Good job!";
}
else
{
cout<<"Work hard!"<<endl<<endl;
}
cout<<"Enter first test score: ";
cin>>a;
cout<<"Enter second test score: ";
cin>>b;
cout<<"Enter third test score: ";
cin>>c;
}
return 0;
}