C++ Programming - Constructors and Destructors - Discussion

Discussion :: Constructors and Destructors - Programs (Q.No.1)

1. 

What will be the output of the following program?

#include<iostream.h> 
class IndiaBix
{
    int x; 
    public:
    IndiaBix(int xx, float yy)
    {
        cout<< char(yy);
    } 
}; 
int main()
{
    IndiaBix *p = new IndiaBix(35, 99.50f);
    return 0; 
}

[A]. 99
[B]. ASCII value of 99
[C]. Garbage value
[D]. 99.50

Answer: Option B

Explanation:

No answer description available for this question.

Anonymous said: (Jul 28, 2012)  
float is converted to int and char(int) gives the ASCII value of 99

Rudraksh said: (Aug 26, 2013)  
Kindly elaborate how float is converted into char(int)?

Nilofer said: (Sep 7, 2013)  
How float is converted into char(int)?

Velmurugan said: (Mar 12, 2014)  
How float is convert into char(int)? Because arithmetic operation float is convert into integer. (i.e) 55.4 is convert into 55.

Iram Zakir said: (Oct 15, 2016)  
What about this 99.50f, what is f?

Is it just misprinting?

Aditya Singh said: (Nov 2, 2016)  
The f denotes 99.50 is a float value.

Aniruddha said: (Jun 1, 2017)  
99 is the ASCII value. Printing char(99) would print the character whose ASCII value is 99 i.e. 'c'.

Alka said: (Jun 3, 2017)  
Yes, it should print C. Whose ASCII value is 99.

Madhubala said: (Oct 2, 2017)  
Please explain properly.

Chandu Reddy said: (Dec 19, 2019)  
Please, can anyone explain deeply? How it converts and why need to convert?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.