Try the following C++ lines and take notes to your notebook

Task-5: Try the following C++ lines and take notes to your notebook.
int a = 3;
char b = ‘f’;
cout << a << '\t' << static_cast(a) << endl; cout << b << '\t' << static_cast(b) << endl; cout << ( 2/3 ) << '\t' << ( static_cast(2) / 3 ) << endl;

Solution : 

Input Screen
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int a = 3;
	char b = 'f';
	cout << a << '\t' << static_cast<char>(b) << endl;
	cout << b << '\t' << static_cast<int>(b) << endl;
	cout << (2 / 3) << '\t' << (static_cast<float>(2) / 3) << endl;
	return 0;
} 

OutPut Screen

Leave a Comment

Your email address will not be published. Required fields are marked *