Follow Us

LightBlog

Breaking

Sunday, May 31, 2020

C++ Program

➤You need to learn how to write, compile, and run the first C++ program.
➤To write the first C++ program, open the C++ console, and write the following code:

Example: 

#include <iostream.h>  
#include<conio.h>  
void main()
 {  
   clrscr();  
   cout << "Welcome to C++ Programming.";   
   getch();  
}  


#include<iostream.h> includes the standard input-output library functions.
It provides cin and cout methods for reading from input and writing to output respectively.

#include <conio.h> includes the console input output library functions.The getch() function is defined in conio.h file.
void main() :The main() function is the entry point of every programming language. The void keyword specifies that it returns no value.
cout << "Welcome to My First C++ Program." 
      cout  is used to print the data "Welcome to My First C++ Program." on the console.
getch() :The getch() function asks for a single character.you press any key, it blocks the screen.

 ➤ How to compile and run the C++ program 

There are 2 ways to compile and run the C++ program, by menu and by shortcut.

By menu: ➜ Now click on the compile menu then compile sub-menu to compile the c++ program. Then click on the run menu then run sub-menu to run the c++ program.

By shortcut:➜  Press ctrl+f9 keys compile and run the program directly.



No comments:

Post a Comment