fork download
  1. /* Answer the following three questions. Each question is awarded one point
  2. 1. what is the national bird of India?
  3. 2.Who is the Prime Minister of India?
  4. 3. Name the capital of Punjab */
  5.  
  6. #include <iostream>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. int x=0;
  12. string ans;;
  13. string ans1;
  14. string ans2
  15. cout << "Answer the following questions";
  16. cout << endl;
  17. cout << "What is the national bird of India?" ;
  18. cout << endl;
  19. cin >> ans ;
  20. if (ans == "Peacock")
  21. { x = x+1;
  22. cout << "Correct! You have scored one point";
  23. }
  24. else
  25. x = 0;
  26. cout << "Wrong answer!";
  27. cout << endl;
  28.  
  29.  
  30. cout << "Who is the Prime Minister of India?";
  31. cout << endl;
  32. cin >> ans1;
  33. if (ans1 == "Modi")
  34. { x = x+1;
  35. cout << "Correct! You have scored one point"; }
  36. else
  37. x = x;
  38. cout << "Wrong answer";
  39. cout << endl;
  40.  
  41. cout << "Name the capital of Punjab";
  42. cout << endl;
  43. cin >> ans2;
  44. if ( ans2 == "Chandigarh")
  45. {x = x+ 1;
  46. cout << "Correct! you have scored one point!!";
  47. }
  48. else
  49. x = x;
  50. cout << "Wrong answer!";
  51. cout << endl ;
  52.  
  53. cout << "Your total score is" << x;
  54.  
  55. return 0;
  56. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Peacock
Modi
asd
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:15:4: error: expected initializer before ‘cout’
    cout << "Answer the following questions";
    ^~~~
prog.cpp:43:11: error: ‘ans2’ was not declared in this scope
    cin >> ans2;
           ^~~~
stdout
Standard output is empty