-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_types.cpp
41 lines (26 loc) · 1.68 KB
/
data_types.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
using namespace std;
int main()
{
// Declare a string variable to store the name.
string name = "Hammad Khurshid"; // 'string' is a data type in C++ used to store text.
// Declare an integer variable to store the age.
int age = 20; // 'int' is a data type in C++ used to store whole numbers.
// Declare a float variable to store the height.
float height = 5.8; // 'float' is a data type in C++ used to store decimal numbers with less range and accuracy.
// Declare a double variable to store the weight.
double weight = 56.150; // 'double' is a data type in C++ used to store decimal numbers with more range and accuracy.
// Declare a char variable to store the gender.
char gender = 'M'; // 'char' is a data type in C++ used to store a single character.
// Declare a boolean variable to store the marital status.
bool married = false; // 'bool' is a data type in C++ used to store true or false.
// Print the details to the console.
cout << "Hello World, My name is " << name << ". I'm " << age << " years old." << " My height is " << height << "Ft, my weight is: " << weight << "KGs" <<" and my gender is " << gender << "." << endl;
return 0;
}
/*
Summary of Concepts:
Data Types: This program demonstrates the use of various data types in C++. Data types define the type of data a variable can hold. The data types used in this program are string, int, float, double, char, and bool.
Variables: Variables are used to store data. In this program, variables are used to store details like name, age, height, weight, gender, and marital status.
Output: The cout statement is used to print the details stored in the variables to the console.
*/