Cycle 01
Datatypes, Variables, Input/Output & Library Functions
Demonstration of Fundamental Datatypes and sizeof Operator
Problem Statement
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.
#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