• Home
  • 1.3 Basic Data Types

1.3 Basic Data Types

View Categories

1.3 Basic Data Types

< 1 min read

Table of Contents

C++ provides fundamental data types for storing different kinds of values. Integer and floating-point types are used to represent numeric data, while character types store individual characters.

This example demonstrates how variables of different built-in data types are declared, initialized, and displayed using the standard output stream.

Source Code #

#include <iostream>

int main()
{
    int account_number = 1024;
    float amount = 100.5f;
    char currency = '$';

    std::cout << "Mr. Cat with account number "
              << account_number
              << " owes me "
              << amount
              << " "
              << currency
              << '\n';

    return 0;
}

Output #

Mr. Cat with account number 1024 owes me 100.5 $

Explanation #

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *