Any help on this C++ program?

#include <stdio.h>

int main()
{
int grade = 76; //variable declaration and initialization

if grade >=60); //decisional statement
{
printf(passed\n"); //output
}
else{

printf("failed\n");

Return 0;
}
Hello coco2991,

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

I would love to help you with your C++ code if you had any. This is a C program.

You should compile the program first and try to understand and take care of as many of the errors as you can before you post. And include the actual error message from the compiler.

The comments in the following code should help you understand what is wrong.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>

int main()
{
	int grade = 76; //variable declaration and initialization

	if grade >= 60); //decisional statement <--- Missing ( and the ';' should not be here.
	{
		printf(passed\n"); // output  // <--- Missing a "
	}
	else {  // <--- Nothng wrong here, but lookls and reads bbetter on the next line.

		printf("failed\n");

		Return 0;  // <--- It is a lowercase "r". And should be after the else statement.
	}
// <--- you may need a pause here to read the screen before the program closes the window.
// <--- Missing closing } of main 


Hope that helps,

Andy
Topic archived. No new replies allowed.