Programmingoneonone is known for sharing best programming knowledge.

how to create a simple c++ program.

in this post, you will learn about how to create a simple c++ program. and also learn about the basic of c++ programming.

a simple c++ program, learn c++ programming
learn c++ programming

A simple c++ program

Note: if you have some knowledge of programming then you can easily understand the program. another wise you just read the steps which are mention and you will completely understand how to create a simple c++ program.

Example code for create a simple c++ program

             #include <iostream>
             int main()


             std::cout<<"Learn c++ programming";
             return 0;
learn c++ programming
program output

Explanation of code of the program:

why I used  <iostream.h>

we include a header file #include <iostream.h> for input-output system. to read the input and print the output we used the iostream.h header file.

iostream include two header files called:


istream is used for console input. we used cin function to get the input in a program.



              cin= object

              >> = extraction operator(get from)
              a  = variable

ostream is used for console output. we used a cout function to print the output at the output screen.


              cout<<"learn c++";

              cout= object

              <<  = insertion operator(put to)
              learn c++ = line of instruction

Note: in cin function, we used >> (twice greater than) operator. and in cout, we used << (twice less than) operator.

Note: mean of #include is that we include this header file.

so I think now you get that why I am used the iostream.h header file.

Main() function:

In an earlier post, I show up you how to declare a main() function. if you don't know how to create the main() function then click here to learn.
and then I used std::cout() function to print the message.
Note: This code is totally compiled and run in Dev c++. and if you want to run the code in any other compiler then you need to add or hide some function. it only depends on the need of the compiler.
if you are a beginner in programming then you should code first in Turbo c++ compiler then you need to go to other compilers.

Note: The compiler is started the compiling the program from the [{] open Curly brackets and ends at [}] close curly brackets.

Continue learning:

"If this post is helpful for you then please share this post as much possible as you can, and also comment me your question in the comment section given below related to this topic. I feel very grateful to help you"

No comments:

Post a Comment