how to make first c++ program !!!
how to make first c++ program !!!

Hello friends, today I am gonna tell you how to make first c++ program !!!

Before start learning  first c++ program??

Make sure you should have  install either gcc or visual studio . It will b better if u’ll install visual studio if u r using windows 7 or 8 , as turbo c++ ‘s compatibility has been removed from windows 7/8  and if you love compiling from cmd you can go for gcc.

To learn compiling with visual studio(for windows) click here and to learn compiling with gcc(for windows and linux both) click here .

Now lets begin with our first c++ program …..

Code:

how to make first c++ program !!!
how to make first c++ program !!!

 How it works??

  • Here the first 2 lines are used for including header files. Header files basically refers to library where some predefined classes and functions are present , well I’ll explain classes and functions later for now lets just concentrate in our program .

“iostream” is used for all input/ outputs operations .

“conio” is used for getch() function .

  • Remember if header files are not included then then we wont b able to use any predefined                                     functions( already defined in c++ library ).
  • For now just include this namespace std too otherwise errors will be generated .
  • Then void main() , it’s a function where basically our main program is written ,hence the name “main “ is given to it. Its also a predefined function so we cant change this name “main “.

Now curly braces “{}” are put . inside these braces our main program is written .

“cout”  is used to display anything on the screen .

Syntax:

Cout<<”whatever you wanna display i.e ur message”;

  • Now comes getch(), it’s a predefined function in conio.h .this function is used to fetch any character.
  • Here it is used to make sure we can see our output .Now  if this getch is not used then the output will come and output window will get close and user will not be able to view the output clearly.

Now press f5 or ctrl+r to run your program.

Voilla your program gets execute !!!

                                                                                                        Next

What to do next:

 

 

NO COMMENTS