Question 01 of 02

Demonstration of Fundamental Datatypes and sizeof Operator

Write a Turbo C++ program to declare variables of various fundamental datatypes (int, float, double, char), initialize them with sample values, and print their values along with their memory size in bytes using the sizeof operator.

C++
Approach 1 / 2
#include <iostream.h>
#include <conio.h>

void main() {
    int i = 25;
    float f = 3.1415;
    double d = 98765.4321;
    char c = 'A';

    clrscr();

    cout << "--- Fundamental Datatypes in Turbo C++ ---" << endl;
    cout << "Integer value: " << i << " | Size: " << sizeof(i) << " byte(s)" << endl;
    cout << "Float value:   " << f << " | Size: " << sizeof(f) << " byte(s)" << endl;
    cout << "Double value:  " << d << " | Size: " << sizeof(d) << " byte(s)" << endl;
    cout << "Char value:    " << c << " | Size: " << sizeof(c) << " byte(s)" << endl;

    getch();
}
Question 1 of 2