Home Declaring and printing variables
Post
Cancel

Declaring and printing variables

Today we will learn how to declare and print variables in C++. In C++, variables can basically be declared of four types namely int,char,double and float.int is for integers,char for characters,float for decimals and double for decimals with higher precision and range.int x declares a variable x of type int. x=10 assigns the value of 10 to x.Then we use cout to print the value of x.

1
2
3
4
5
6
7
8
9
10
11
#include<iostream>
using namespace std;
int main()
{
    int x;
    x=10;
    cout<<"x="<<x;
    return 0;
}

OUTPUT:

output

This post is licensed under CC BY 4.0 by the author.

Trending Tags