Sail E0 Webinar
Question


What is the output of the following program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int a = 5;
6.
float b;
7.
cout
Options:
A .  2 6
B .  4 6
C .  2 5
D .  4 5
Answer: Option D

The a as a integer will be converted to float while calculating the size. The value of any variable doesn’t modify inside sizeof operator. Hence value of variable a will remain 5.
Output:
$ g++ size3.cpp
$ a.out
4 5



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers