Basic Coding in c++

The first code in C++ was to print a string "Hello, World".
Below is the code to print the same.





#include<iostream> 
using namespace std;
int main()
{
cout<<"Hello, World";
return 0;
}




Now, Let me introduce some of the keyword used in the code.
1. Iostream-It’s a set of classes, templates, and library functions that are part of the standard library in C++ that are used to perform input, output, and various formatting operations.
The IO is from Input/Output (IO), and Stream is because it’s a (potentially endless) flow [or “stream”] of characters.
2. Using namespace std-A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it. Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.
3. coutThe cout object in C++ is an object of class ostream. It is used to display the output to the standard output device i.e. monitor. It is associated with the standard C output stream stdout.
4. '<<'- This is called as Extraction Operator or 'put to' operator and is used to print output of the program.
2. Code To Print The Sum Of Two Numbers
For adding two numbers in C++, We first need to declare to variables in the main function which will be used to take input from the user or some values will be assigned to the variables using assignment operator('='). Further '+' operator will be used for calculating the sum. The code to calculate the same is as follows:



#include<iostream>
using namespace std ;
int main()
{
int a, b, sum; //#1
cout<<"Enter the two numbers"; 
cin>>a>>b; //#2
sum=a+b; 
cout<<"sum of "<

'//'- This operator is used to put comment in between the codes and will get ignored by the compiler during compilation. Here #1, #2 ,#3 are the comments.
#1- This is the way to declare the variables. Here we have declared three variable of int(Integer) catogary.
#2- Cin is the object of istream class and is used to scan the inputs from the user. '>>' this is called as insertion operator or 'get to' operator.  Here we are simultaneously scanning two values from the user , but we are using cin only once , This is called as casecading of cin object.
#3- In this step we have wriiten two cout statements to print the output where as ssame can be done using only one cout operator via casecading. (cout<<"sum of the two above entered number is ="<<sum;)
Result obtained on running:
let the number entrered by user is 5 & 7.