C++ Basic syntex and structure - C++ Tutorials                               Bestitworriors


C++ Basic syntex and structure




C++ Basic syntex and structure - C++ Tutorials - Bestitworriors  - C++ file name having extenssion filename.cpp.C++ is very simple and easy to understand and write code.In c++ file first we include the library files #include after that we write using namespace std then we define main function int main(){//coder }.In main function we return 0 .This return 0 means we tell the operation system that code is working fine and every thing is normal.Then operation system execute our c++ code.C++ support single line and multiline comment



 

Some Key Points of C++ basic syntex and structure

  1. C++ filename extenssion contain filename.cpp
  2. First include library files #include
  3. After include library files we write using namespace std;
  4. In c++ every statement end with semicollen ";"
  5. Must define main function
  6. C++ print output using cout<<"output";
  7. C++ taking input using cin>>variable;
  8. Must return 0 in main function
  9. Single line comment //comment
  10. Multilines comment /* Multiple lines */
  11. In c++ endl and \n use to line break

Code




# include <iostream>
using namespace std;

int main()
{
cout << "Best It Worrior is best platform";
cout << endl;

// Comment
/ * Multilines
commentl
* /
int
var1;
cout << "Type a number: "; // Type
a
number and press
enter
cin >> var1; // Get
user
input
from the keyboard

cout << "Your number is: " << var1; // Display
the
input
value
return 0;
}




OutPut



                                                 

                  Best It Worrior is best platform
                  Type a number: 3
                  Your number is: 3








I hope You really enjoyed this blog . I try my best to make every thing is easy and helpfull to provide to public .You will get more blog about the Programing project and code . Thanks for visiting my blog if you have any querry related to this you can comment here i will try my best to response you back