# Difference between Compile Time Errors and Runtime Errors in C Program

CServer Side ProgrammingProgramming

Error or exception is something that refers to the interruption of code execution due to which the expected outcome could not be attained to the end-user.On the basis of the event when an error is generated or identified we can classify them as Compile time error and runtime error.

The following are the important differences between Compile Time Errors and Runtime Errors.

Sr. No.KeyCompile Time ErrorsRuntime Errors
1ReferenceCompile-time errors are generally referred to the error corresponding to syntax or semantics.Runtime errors on the other hand refer to the error encountered during the execution of code at runtime.
2DetectionCompile-time errors get detected by compiler at the time of code development.Runtime time errors are not get detected by compiler and hence identified at the time of code execution.
3FixationCompile-time errors as already mentioned can get fixed at the time of code development.Runtime time errors are getting to fixing state after once code get executed and errors get identified.

## Example of Compile time errors vs Runtime time errors

CompileDemo.c

#include<stdio.h>
public class CompileDemo{
void main(){
int x = 100;
int y = 155;
// semicolon missed
printf("%d", (x, y))
}
}

## Output

error: expected ';' before '}' token

## Example

RuntimeDemo.c

include<stdio.h>
public class RuntimeDemo{
void main(){
int n = 9;
div = 0;
div = n/0;
printf("resut = %d", div);
}
}

## Output

warning: division by zero [-Wdiv-by-zero]
div = n/0;
Published on 18-Sep-2019 11:49:02