Difference between Compile Time and Run Time

 Compile Time : 

It is a Time window During which a Program is Compiled. During Compilation , a source code or program is converted into machine code.

There are two types of errors in Compile Time known as Compile Time errors :

  • Syntax Error
  • Semantic Error
Syntax Error : 

The Error occurs due to mistake in syntax or predefined way of writting a programm during compilation is called Syntax Error.

Example : 

#include<iostream>
using namespace std;

int main()
{
    int a = 10:        // Every statement should be ended with an ' ; ' (semicolon) , but here it is ended with 
                            // ' : ' (colon) it is an syntax error.
    int b = 20;
    return 0;
}

Semantic Error : 

The wrong and meaningless code/statement in a programm are called Semantic Errors.

Example : 

int main()
{
    int a, b, c;
    a + b = c;        // It is a meaningless statement because the operations done on right side of the code
                            // must be stored in one and only single variable present in the left side.
    return 0;
}

Run Time : 

It is a time window during which a Compiled program is executed or in a process of execution. Here is no Role of Compiler because the program is already compiled and is in running process.

Run Time Error : 

During Run Time the Error occurs is detected by the User itself only. 

Example : 

#include<iostream>
using namespace std;

int main()
{
    int a = 10 , b = 0 , div;
    div = a / b;
    return 0;
}

"Note : The number divisible by 0 is undefined so here occures a run time error"
    

Comments

Popular posts from this blog

A program to Add numbers divisible by 3 or 5 in C++

When only Some specific user name will be greeted in a C++ Program.

C++ Programming Language Easy Course