Understanding the Programming language Concept with example

Understanding the Programming language Concept with example

3 min read


Let’s take a look at our very first program and discuss all the things about it:

// first program 
#include <iostream.h>
 int main() { 
       cout<<"Hello World";        
       return 0; 


Hello World

Let’s now understand the meaning of each instruction.

//first program

This is a c++ comment. Comments are useful for a better understanding of the program. They are not executed by the compilers. A single-line comment starts with ‘//’ and a multiline comment is included between /*—-*/.


The statement starts with a # which is known as preprocessor directives, which means these kinds of statements are processed before compilation. Then include<iostream.h> indicates the compiler’s preprocessor to include header file iostream.

int main()

The main() indicates the beginning of the program. Here int is the datatype of main.

cout<<“Hello world”;

It is the most important instruction. The cout is the standard output stream i.e, its function is to give output on the screen.<< is the output operator. Hello world is the message we want to put on the screen.

Since cout is declared in header file iostream.h, thus to use cout we have included iostream.

return 0;

It makes the main() to finish the program and it returns a value, here it is 0.

BKKB(Bade Kaam Ki Baat):-

  1. The whole program is included in curly braces'{ }’.
  2. Every instruction of the program terminates with ‘;’.
  3. Cin is used for taking inputs along with input operator’>>’.Its header file is iostream too.
  4. The multiple uses of I/O operators(<< or >>) are known as cascading of I/O operator.

Just like iostream there are many other files which we will be including in later.


The duty of compiler is to analyze the program code for correctness and find errors.

Some common forms of program errors are

Syntax Error

  • Syntax simply means the structure
  • It occurs when rules of programming language are misused.

for example

int main()
     cout<<"Welcome to Freshly built";

     return 0;


Here the highlighted instruction cause error because it is not terminated.

Semantics Error

  • It occurs when statements are not meaningful.
  •  For instance- The sentence ‘sita plays piano’ is semantically correct. but ‘piano plays Sita’ is wrong. Here, in case of coding such errors occurs such as:

Type Errors

Errors which occur in the associated data type as in giving a character value to a float type variable.

  • Run-time Errors – Errors that occurs during the execution of a  program. It is caused by some illegal operations taking place or unavailability of the desired condition. Just in case when the compiler is not able to open any required file or when a number is divided by zero.
  • Logical Errors – A Logical error is one that causes a program to produce incorrect output.

If you liked my article please follow me on @priya123 for the latest article by me.

Choose your Reaction!
Leave a Comment