Skip to content

This C++ program demonstrates basic data types (int, float, string, double, char) and displays their memory size using sizeof(). It takes user input for each type and prints the value along with its size in bytes. Ideal for beginners exploring C++ fundamentals and type handling.

Notifications You must be signed in to change notification settings

harshikasGH/Data-Types-in-CPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Data Types in C++

Aim To understand and explore various primitive data types in programming, with a focus on their usage in C++.

Theory Primitive data types are the fundamental building blocks of any programming language. In C++, they are used to store and manipulate basic forms of data such as numbers, characters, and logical values.

Common Data Types in C++

Data Type Description Example
int Stores whole numbers without decimals int marks = 25;
float Stores single-precision decimal numbers float x = 3.2f;
double Stores double-precision decimal numbers double a = 9.97585858;
char Stores a single character char initial = 'A';
bool Stores logical values: true or false bool isStudent = true;
string Stores a sequence of characters (text) string name = "Aditya";

Note: In C++, string is part of the Standard Library and requires:

#include <string>
using std::string;

Conclusion Mastering data types is essential for writing reliable, efficient, and expressive programs. Each type—whether it's an integer for counting, a float for precision, or a string for text—serves a unique purpose in representing and manipulating information.

By understanding how and when to use these types, you lay the groundwork for structured logic, memory management, and robust application development in C++. 🧱💻

About

This C++ program demonstrates basic data types (int, float, string, double, char) and displays their memory size using sizeof(). It takes user input for each type and prints the value along with its size in bytes. Ideal for beginners exploring C++ fundamentals and type handling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages