+ 1
Whats wrong can anyone correct it
3 Answers
+ 4
You have several unused variables (mark, percentage), and you were assigning <a> to <mark>, and <p> to <percentage> while <a> and <p> haven't been properly assigned a value. Also it might be more appropriate to use floating point type for marks & percentage since these values usually have fraction.
#include <iostream>
using namespace std;
int main()
{
int a, x;
cout << "Enter your Marks and total marks:";
cin >> a >> x;
cout << endl << a << endl << x << endl;
if (a < 50) {
cout << "You failed." << endl;
} else {
cout << "You passed." << endl;
}
float p = ((float)a / x) * 100;
cout << "Your percentage is: " << p;
}
Hth, cmiiw
+ 2
Thanks
0
You're welcome, glad if it helps. : )