problem

Im a beginner. What is wrong?
---------------------------------------------
#include <iostream>
using namespace std;

int main()
{
char Abfrage;

cout << "Bitte 'A' eingeben!" << endl;
cin >> Abfrage >> endl;
cout << "Wird geprüft..." << endl;
system("PAUSE");

if (Abfrage == 'A')
{
cout << "Sie haben 'A' gedrueckt!" << endl;
system("PAUSE");
}
else if
{
cout << "Sie haben nicht 'A' gedrueckt!" << endl;
system("PAUSE");
}
return = 0;
}
Firstly, this:
cin >> Abfrage >> endl;
How can you input to endl? endl is "end of line". It's for outputting.


return = 0;
Did you mean return 0;?

else if
else if what? Did you mean else?

system("PAUSE");
This is very bad practice. Please don't do it.
Last edited on
Also you can substitute these statements

1
2
3
4
5
6
7
8
9
10
if (Abfrage == 'A')
 {
 cout << "Sie haben 'A' gedrueckt!" << endl;
 system("PAUSE");
 }
 else if
 {
 cout << "Sie haben nicht 'A' gedrueckt!" << endl;
 system("PAUSE");
 }


for this one

1
2
 cout << "Sie haben " << ( ( Abfrage == 'A' ) ? "" : "nicht " )
        << "'A' gedrueckt!" << endl;
Topic archived. No new replies allowed.