C++ Basic syntex and structure - C++ Tutorials Bestitworriors
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
- C++ filename extenssion contain filename.cpp
- First include library files #include
- After include library files we write using namespace std;
- In c++ every statement end with semicollen ";"
- Must define main function
- C++ print output using cout<<"output";
- C++ taking input using cin>>variable;
- Must return 0 in main function
- Single line comment //comment
- Multilines comment /* Multiple lines */
- 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
0 Comments