Raza Bayani

Basic Programs in C++ to Understand the Structure and Logic

Basic Programs in C++ to Understand the Structure and Logic

For understanding most of the programming languages and their structures along with their logic they use, you have to start with basic programs and go on through them to reach the high level. C++ is an OOP (Object Oriented Programming) language. Here we are not going through the OOP concept but to we will show you some basic programs in-order to make you understand the Logic and Data Structures in CPlusPlus.

1- Compiler:

C++ programs must be written in an IDE having compiler – in-order to compile the c++ codes to binary.

2- Libraries:

CPP built-in functions and classes which are inside different libraries, must be included before using them. E.g. the standard library which is necessary to use for using “cout”, “cin”, “endl” and many other functions inside our program is “iostream“.

3- Program Execution:

While executing a program, Operating System calls the “main”  function from the program. Thus we need to include main function.

As you see “main”  function is a value returning function, therefore it returns to Operating System.

If you are not familiar with the code read this article (Introduction to Functions in C++)

4- Some Basic Programs Written inside Main Function

  • Printing “Hello World”
  • Comparing three numbers:
  • Generating Random Numbers till 1000:
  • Swap values of two variable: (Int / String):
    Read about Variable in C++: Intro to variables



Raza Bayani
Raza Bayani

Raza Bayani studies BCE (Bachelor in Computer Engineering) in Poly-technical University of Kabul. He is the CEO of CODEJOW group, a web designer, coder and recently a blogger. Raza thinks, he can help others and also boost-up his own programming skills being on codejow.com.

Related Posts
%d bloggers like this: