Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

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
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
Sanjay PrasadClearner Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of
Clearner
Guest
Clearner

Will you publish more c++ tutorial with example …..

Do you have any Query / Suggestion