×

C Programs

C Basic & Conditional Programs

C Looping Programs

C String Programs

C Miscellaneous Programs

Error: Expected ';' before 'return' in C | Common C program Errors

Here, we will learn how and when Expected ';' before 'return' error occurs and how to fix this error in C program?
Submitted by IncludeHelp, on August 23, 2018

Error: Expected ';' before 'return' in C

As we know that each statement (expect some of the statements like conditions, loops etc) must be terminated by the semicolon (;). This is a common error in C program, when we miss semicolon (;) after any statement. In that case, compiler throws an error Expected ';' before 'return' in C.

Program

#include <stdio.h>

int main(void) {
	printf("Hello world")
	return 0;
}

Output

prog.c: In function 'main':
prog.c:5:2: error: expected ';' before 'return'
  return 0;
  ^~~~~~

How to fix Expected ';' before 'return' in C error

To fix this error, check the statement (line no.) which is written before the statement in which compiler throws the error.s

Error free code

#include <stdio.h>

int main(void) {
	printf("Hello world");
	return 0;
}

Output

Hello world

C Common Errors Programs »

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.