๐Ÿ‡ฎ๐Ÿ‡ณ India's Free Coding Tutorial โ€” Learn C, PHP, MySQL, Python, Java About ยท Contact
Advertisement

Variables & Data Types in C++

C++ Language Variables & Data Types ๐Ÿ“… Mar 2026 โฑ 5 min read ๐Ÿ†“ Free

Variables in C++

cpp
#include <iostream>
#include <string>
using namespace std;
int main() {
    int    age     = 20;
    double salary  = 50000.75;
    char   grade   = 65;   // A
    bool   isPass  = true;
    string name    = "Gagan";
    
    cout << "Name:   " << name    << endl;
    cout << "Age:    " << age     << endl;
    cout << "Salary: " << salary  << endl;
    cout << "Grade:  " << grade   << endl;
    cout << "Passed: " << boolalpha << isPass << endl;
    return 0;
}

auto keyword (C++11+)

cpp
auto x = 42;          // int
auto y = 3.14;        // double
auto z = "Hello";     // const char*
auto s = string("Hi");// string

cout << typeid(x).name() << endl;  // i (int)
Advertisement
โ† Back to C++ Language Index