-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab9_q11.cpp
31 lines (25 loc) · 1.28 KB
/
lab9_q11.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
/*Write a program to declare variables of all predefined sizes and declare corresponding pointers (of all predefined types). Print out the sizes of each of variables and pointer variables. (Hint: use sizeof )*/
//include library
#include <iostream>
using namespace std;
int main () {
// declarations of variables
int a ;
char b ;
bool c ;
double d ;
float e ;
//declaration of pointers
int *pint = &a ;
char *pchar = &b ;
bool *pbool = &c ;
double *pdouble = &d ;
float *pfloat = &e ;
//printing size of all the above
cout << "Welcome to question no 11" << endl;
cout << "The size of integer variable is " << sizeof(a) << " and the size of int pointer varible is " << sizeof(pint) << endl;
cout << "The size of character variable is " << sizeof(b) << " and the size of char pointer varible is " << sizeof(pchar) << endl;
cout << "The size of bool variable is " << sizeof(c) << " and the size of bool pointer varible is " << sizeof(pbool) << endl;
cout << "The size of double variable is " << sizeof(d) << " and the size of double pointer varible is " << sizeof(pdouble) << endl;
cout << "The size of float variable is " << sizeof(e) << " and the size of float pointer varible is " << sizeof(pfloat) << endl;
}