+ 1
How do i make this work? It is supposed to to let you insert two variables (a name and score) and print the mark.
#include <iostream> using namespace std; int main() { int name,score; int standard=50; cin >> name; cin >> score; cout << "The performance of" << name << "is:" << score << endl; if(score>=standard){ cout << "Pass" << endl;} if(score==100){ cout << "Perfect"; } else{ cout << "Fail"; } return 0; }
4 Respostas
+ 1
Agreed with Choe , <name> should be using string.
And to add a little, for score decision you can use `else if` too ...
if(score >= standard)
{
if(score == 100)
{
cout << "Perfect" << endl;
}
else
{
cout << "Pass" << endl;
}
}
else
{
cout << "Fail" << endl;
}
+ 2
name is an int. We cant have names like that 😄
#include <string>
string name;
+ 1
Use new lines to separate multiple inputs.
Alice
42
0
But it doesn't work. It just says compilation error