PDA

View Full Version : C++ Problem, please help...?


Ehsan
03-31-2007, 01:30 PM
I wrote this program, first I should say I'm an amature and I'm learning C++.
When I run this program if the input is a letter it returns you havent passed, but if the input is a number then the program halts and got hangged. whats the prob whit this program?
Im using DEV-C++ compiler


#include
#include
int main()
{
int grade;
printf("Please enter your grade: ");
scanf("%d",grade);

if(grade > 10)
{
printf("Your have passed the test.\n");
system("pause");
}
else
{
printf("You havent passed the text.\n");
system("pause");
return 0;
}
}

justme
03-31-2007, 03:45 PM
looks like you forgot the line "return 0;" after the system("pause"); line in your IF statement. you have it for the ELSE, but not the IF.

Reverse Swing
03-31-2007, 04:45 PM
change the statement :-
scanf("%d",grade); to scanf("%d",&grade);