Variable

After you learn how to show hello world to the output, you need to learn how to use variable. Variable is used to store number, string or other value depend on the type of that variable. Variable need to be declared before you can use it. Here is how you can declare a variable and initiate it.

Data_type variable_name=first_value;

After you declare a variable you can use cout to show the value of the variable. Below, we declare a variable with string as data type.

#include <iostream>

using namespace std;

int main(){
    string var="Variable Value";
  
    cout << var;
    return 0;
}
Output :
Variable Value

String type is used to store some characters. You need to write string value between two apostrophes. That value is called as string literal.

You don't need to initiate the value directly. You can declare variable without any value. First value can be empty string, zero (0) or a random number. It will be depend compiler.

#include <iostream>

using namespace std;

int main(){
    string var;
    var="Variable Value";
  
    cout << var;
    return 0;
}
Output :
Variable Value

Number

Above, you have been learn how to print a variable with string data type. Other data of variable are numbers. There are float for storing a decimal fraction number. You can also use int to store any integer value.
#include <iostream>

using namespace std;

int main(){
    int var1=23;
    float var2=23.5;
  
    cout << "Integer : " << var1 << endl;
    cout << "Fraction : " << var2;
    return 0;
}
Output :
Integer : 23
Fraction : 23.5

There are other data types. But learning is need step and progress. So, I'll stop here and continue in other posts.