Write a program to use different formats of typecasting and display the converted values.
# include <iostream.h>
# include <conio.h>
void main()
{
int a=66;
float f=2.5;
double d=85.22;
char c=’K’;
clrscr();
cout <<“\n int in char format : “<<(char)a;
cout <<“\n float in int format : “<<(int)f;
cout <<“\n double in char format : “<<(char)d;
cout <<“\n char in int format : “<<(int)c;
}
OUTPUT:
int in char format : B
float in int format : 2
double in char format : U
char in int format : 75
Explanation
In the above program, the variables of int, float, double and char type are declared and initialized.
The variable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.