-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatatypes.cpp
36 lines (32 loc) · 1.03 KB
/
datatypes.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
/*Exp-2_ Data types in C++*/
#include<iostream>
int main()
{
using namespace std;
int myintvar; float myfloatvar; double mydoublevar; char mycharvar;bool myboolvar;
string mystrvar;
cout<<"Enter a integer no.:";
cin>>myintvar;
cout<<"Enter a float no.:";
cin>>myfloatvar;
cout<<"Enter a double no.:";
cin>>mydoublevar;
cout<<"Enter a char no.:";
cin>>mycharvar;
cout<<"Enter a bool no.:";
cin>>myboolvar;
cout<<"Enter a string:";
cin>>mystrvar;
cout<<"Integer no.:"<<myintvar<<endl;
cout<<"Float no.:"<<myfloatvar<<endl;
cout<<"double no.:"<<mydoublevar<<endl;
cout<<"char :"<<mycharvar<<endl;
cout<<"bool:"<<myboolvar<<endl;
cout<<"string:"<<mystrvar<<endl;
/*To check the size of each data type*/
cout<<"Size of intvar:"<<sizeof (myintvar)<<"bytes"<<endl;
cout<<"Size of floatvar:"<<sizeof (myfloatvar)<<"bytes"<<endl;
cout<<"Size of doublevar:"<<sizeof (mydoublevar)<<"bytes"<<endl;
cout<<"Size of charvar:"<<sizeof (mycharvar)<<"bytes"<<endl;
cout<<"Size of boolvar:"<<sizeof (myboolvar)<<"bytes"<<endl;
}