-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4ref_typecast.cpp
More file actions
30 lines (26 loc) · 862 Bytes
/
Copy path4ref_typecast.cpp
File metadata and controls
30 lines (26 loc) · 862 Bytes
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
#include<iostream>
using namespace std;
int main(){
//float, double and long literals
float d = 43.2f;
long double e = 43.2l;
cout<<"The size of 43.2 is "<<sizeof(43.2f)<<endl;
cout<<"The size of 43.2 is "<<sizeof(43.2F)<<endl;
cout<<"The size of 43.2 is "<<sizeof(43.2l)<<endl;
cout<<"The size of 43.2 is "<<sizeof(43.2L)<<endl;
cout<<"The size of 43.2 is "<<sizeof(43.2)<<endl;
//reference variables
float a = 91.3;
float & x = a;
cout<<a<<endl;
cout<<x<<endl;
//typecasting : used to change the datatype of variables
int k = 22;
float n = 66.98;
cout<<"\nThe value of k is "<<k<<endl;
cout<<"The value of k is "<<(float)k<<endl;
cout<<"The value of n is "<<n<<endl;
cout<<"The value of n is "<<(int)n<<endl;
cout<<"The sum of k and n is "<<k+(int)n<<endl;
return 0;
}