How to make the first program of C ++?

C++ Programming Tutorial

How to make the first program of C ++?

The C ++ program is a collection of statements and comments. Let's look at the first C ++ program.

Download Turbo C++ software.

Download turbo C++ from many sites and click here. Download Turbo c++

#include<iostream.h> #include<conio.h> int main() { clrscr(); cout<<"Welcome to the C++ program."; getch(); return 0; }
Welcome to the C++ program.


The command to include the iostream header, which is used for cin/cout.iostream stands for input/output stream, allowing you to access the output screen or allow the user input.

#include <conio.h>

It allows you to access the user screen, but it's used for specific purposes (getch () to hold the output screen in Turboc++, and clrscr to clear the output screen).

cout << "Welcome to C++ Programming."

It is used to print the data "Welcome to C++ Programming." on the console. When running the program and display it on the console.

How to compile and run the C++ program using Turbo C++ software.

There are two ways.

  1. By menu.

  2. By shortcut keys.

1.By menu.

c++ compiler download
C++ compile

c++ compiler

2.By shortcut keys.

  1. Alt+F9 -> compile.

  2. ctrl+f9 -> Run.

Download code blocks software.

Download code blocks from site, click here. Download code blocks software

#include<iostream> using namespace std; int main() { cout<<"Welcome to the C++ program."; return 0; }
Welcome to the C++ program.

Let's separate this whole program and know about all its parts.

1. #include<iostream>

C ++ offers a variety of headers, with each header containing relevant information for programs to work properly. This particular program is called the header. And the number sign # that is placed at the beginning of the program is used to target the compiler preprocessor. In this case, #include tells the preprocessor to include the header. Note The header defines the standard stream objects that act to input and output data. The C ++ compiler ignores the free space. In general, you can use the empty space to make the program code readable and its good structure. In the above program.

2.using namespace std;

Must have seen so using namespace std;

Tells the compiler to use the standard namespace. The std namespace includes the features of the C ++ Standard Library. The execution of the program starts with main function, int main (), and the entry point of any C ++ program is main () no matter what the program does. Curly brackets {} display the beginning and end of the function, also known as the function body. Information written inside curly brackets {} shows what the function will do when it executes. Next line,

3.cout<<"Welcome to the C++ program.";

We make it to print in the "Welcome to the C ++ program" display. In C ++, streams are used to perform input and output operations. In most programming environments, the screen is the standard Default output destination. In C ++, cout is the stream object that is used to access it. The cout is used as a combination with the insertion operator. The insertion operator is written as <<. After this, the letters written on the screen are visible to us. Note: In C ++, semicolon (;) is used to terminate the statement. As you saw (cout << "THIS IS MY FIRST C ++ PROGRAM";) here. Each statement ends with a semicolon (;). This represents the end of a logical expression.

What are Statements?

A block is a set of logically connected staments. Surrounded by opening {and closing} braces. like:

{ cout<<"Welcome to the C++ program."; return 0; }

Note: You can write multiple statements on a single line. But you have to keep in mind that at the end of each statement you have to terminate it with a semicolon. If you do not put a semi column, the program will be an error.

4.What is the return or what is the use of return?

Last instruction return statement is in the program. Line return 0; terminates the main () function, and returns the value zero to the calling process. A value other than zero indicates that the program has an abnormal termination. If the return statement is not written then the C ++ compiler implicitly returns 0; Inserts it at the end of the function.