C++ Syntax or Program Structure with Working example

C++ Syntax or Program Structure with Working example

C++ Syntax or Program Structure with Working example : In this tutorial we will understand C++ Syntax or Program Structure with the help of a simple working programme called name.cpp, which take input and print name on screen.

About C++ as per Wikipedia

C++ (pronounced cee plus plus) is a general-purpose programming language. It has imperative, object-oriented and generic programming features, while also providing facilities for low-level memory manipulation.

IDE and compiler

  • IDE : CodeBlocks
  • Compiler : GCC
  • Environment : Linux, Window 7

Create a file called name.cpp using Codeblocks or ide of your choice with code given below , compile and run it


#include <iostream>
using namescape std;
int main(){
char str[40];
cout<<"Enter your Name"; //cout used to print something
cin>>str; //cin used to received inputs
cout<<"Your Name is "<<str;
return 0;
}

Points To be Remember

  1. <iostream> means included header iostream.h
  2. The line using namespace std; tells the compiler to use the std namespace.
  3. // used for single line comment
  4. main() is where program execution begins.
  5. return 0; terminates main( ) function and causes it to return the value 0 to the calling process.

2 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Do you have any Query / Suggestion