• Home
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React.js
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Brainstorm
STEMTrainingGrounds
  • Courses
    • Home
    • JavaScript
      • Introduction to JavaScript
      • JavaScript Developer
    • TypeScript
      • Introduction to TypeScript
      • TypeScript Developer
    • React
      • Introduction to React
      • React Developer
    • Python
      • Introduction to Python
      • Python Developer
    • C++
      • Introduction to C++
      • C++ Developer
    • C Language
      • Introduction to C
      • C Developer
    • Rust
      • Introduction to Rust
      • Rust Developer
    • Zig
      • Introduction to Zig
      • Zig Developer
    • Linux Shell
      • Introduction to the Linux Shell
      • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Reading Grounds

Quick Links

  • About Us
  • Pricing
  • Partnership
  • Brainstorm
  • Terms
  • Privacy
  • Refunds

Courses

  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer

Newsletter

Subscribe to our free monthly newsletter, for a quick update on Python, JavaScript, and React news

© 2025 - 2026 STEMTrainingGrounds. All Rights Reserved.

C++ Developer -

Lesson 3 of 22

Lesson Progress: 0%

Lesson Progress: 0%
Lesson Incomplete
← Previous: Variables
Lesson 3 of 22
Next: Constants →

In C++, every piece of data has a type that tells the compiler what kind of value it holds. The most common basic types are int for whole numbers, double for decimal numbers, char for a single character, bool for true or false, and string for text. Choosing the right type is important because it determines what you can do with the data and how much memory it uses. This lesson will introduce each basic data type and show how to use them in your programs.

Code Example
#include <iostream>
using namespace std;

int main() {
    int age = 10;
    string name = "Bob";
    cout << name << " is " << age;
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Cpp Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • int stores whole numbers like 10 without any decimal part.
  • string stores text like "Bob" and must be in double quotes.
  • The program prints the string value followed by the int value.
  • The output is Bob is 10.
Code Example
#include <iostream>
using namespace std;

int main() {
    double price = 4.99;
    cout << "Price: " << price;
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Cpp Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • double stores decimal numbers like 4.99.
  • Use double when you need to represent fractional values like prices or measurements.
  • The program prints Price: 4.99.
Code Example
#include <iostream>
using namespace std;

int main() {
    char grade = 'A';
    cout << "Grade: " << grade;
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Cpp Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • char stores a single character like 'A'.
  • Character values must be enclosed in single quotes, not double quotes.
  • The program prints Grade: A.
Code Example
#include <iostream>
using namespace std;

int main() {
    string city = "London";
    cout << "City: " << city;
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Cpp Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • string stores a sequence of characters like "London".
  • Strings must be surrounded by double quotes.
  • The program prints City: London.
Code Example
#include <iostream>
using namespace std;

int main() {
    bool isReady = true;
    cout << isReady;
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Cpp Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • bool stores a truth value: either true or false.
  • When printed, true shows as 1 and false shows as 0.
  • Booleans are useful for conditions and flags in your programs.
Code Example
#include <iostream>
using namespace std;

int main() {
    int count = 7;
    double cost = 2.5;
    cout << count * cost;
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Cpp Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • You can use different data types together in expressions.
  • int count = 7; stores a whole number and double cost = 2.5; stores a decimal.
  • Multiplying an int and a double produces a double result.
  • The program prints 17.5.

Test Incomplete

Which data type is used for whole numbers in C++?

Question #

1/15

Score

0/0 - 0.0 %