0
Why does this code work in the code playground but not in Codeblocks?
#include <iostream> using namespace std; int main() { int score; cout << "Please enter score" << endl; cin >> score; if(score>=70) { cout << "You got an A*"; } if (score>=60 && score<70) { cout << "You got an A"; } if (score>=50 && score<60) { cout << "You got a B"; } if (score>=40 && score<50) { cout << "You got a C";} if (score<40) { cout << "You have failed";} return 0; } In code blocks, for example when I input 50 I get nothing back (Please enter score 50 Process returned 0 (0x0) execution time : 5.076 s Press any key to continue. ) Whereas a score of 55 outputs Grade: A Please could someone tell me whats going on
2 Answers
0
Hmm it seems that in Code Blocks, the program automatically closes the command prompt (or terminal) once the program is finished. Try putting system("PAUSE"); or getchar() before your return to keep the command prompt open.
0
Thanks for response! Although code blocks doesn't seem to like it..