-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypecasting.cpp
More file actions
32 lines (28 loc) · 1.08 KB
/
Copy pathtypecasting.cpp
File metadata and controls
32 lines (28 loc) · 1.08 KB
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
//type conversion or implicit conversion
//typecast or explicit conversion
#include<iostream>
using namespace std;
int main(){
//implicit conversion means conversion of one data type to other by the compiler automatically without cast
// soft casting
// float a=2;//here 2 is int but can be easily stored in float box
// double b=3.7f;//we can easily store float value inside double box
// int d='A';//here charecter is of one byte can be easily store after typcast to int by the compiler.
// char e=65;
// cout<<e<<endl;
// hard casting
// int c=3.7;//here float value is automatically round of by comiler to store inside int box;
// cout<<c<<endl;
//explicit conversion means conversion of one data to other using casting with the required data type by the developer
//hard casting
// int g=65;
// char h=(char)g;
// cout<<h<<endl;
// double arr[]={65.7,66.3,67.4};
// for (int i = 0; i < 3; i++)
// {
// // cout<<(char)arr[i]<<endl;
// cout<<(char)(int)arr[i]<<endl;
// }
return 0;
}