+ 1

Whats wrong can anyone correct it

https://code.sololearn.com/ci3eaSL46wnW/?ref=app

18th Jan 2019, 4:27 AM
Darren Gonsalves
Darren Gonsalves - avatar
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
18th Jan 2019, 6:35 AM
Ipang
+ 2
Thanks
18th Jan 2019, 7:39 AM
Darren Gonsalves
Darren Gonsalves - avatar
0
You're welcome, glad if it helps. : )
18th Jan 2019, 8:34 AM
Ipang