C++ Programming - Functions - Discussion
Discussion Forum : Functions - Programs (Q.No. 21)
21.
What will be the output of the following program?
#include<iostream.h>
class IndiaBix
{
int K;
public:
void BixFunction(float, int , char);
void BixFunction(float, char, char);
};
int main()
{
IndiaBix objIB;
objIB.BixFunction(15.09, 'A', char('A' + 'A'));
return 0;
}
void IndiaBix::BixFunction(float, char y, char z)
{
K = int(z);
K = int(y);
K = y + z;
cout<< "K = " << K << endl;
}
Discussion:
14 comments Page 1 of 2.
Arpan said:
5 years ago
K is initialized within a class without access specifier, so by default it will be private. How they are able to use K outside the class?
(1)
Azad rahul said:
6 years ago
But in the formal parameter, there is no variable of float. Its is compiler time error;.
Anomii said:
7 years ago
The char overflow is not guaranteed to wrap around into the negatives. That is undefined behavior according to the standard.
So, please anyone explain it clearly with the correct solution.
So, please anyone explain it clearly with the correct solution.
Sarvesh karan said:
7 years ago
Maybe It should give error as lvalue required.
I don't know how you all compiled it, but what I saw is;
BixFunction(float, char y, char z)
Don't we require to set a variable for float value.
Float argument don't have any variable to hold it.
But still, it compiled on GCC
And the answer was k=195.
Did char was taken as unsigned char?
130+65.
I don't know how you all compiled it, but what I saw is;
BixFunction(float, char y, char z)
Don't we require to set a variable for float value.
Float argument don't have any variable to hold it.
But still, it compiled on GCC
And the answer was k=195.
Did char was taken as unsigned char?
130+65.
Georg said:
8 years ago
Please correct it. The solution can never ever be "M = whatever". The output has to start with "K = ".
Max said:
8 years ago
@ALL.
cout<< "K = " << K << endl; so it will 100% print "K = ", wtf is answer "M = "?
cout<< "K = " << K << endl; so it will 100% print "K = ", wtf is answer "M = "?
Anonymous said:
8 years ago
This is BS question! Why you are supposed to remember ASCII table and exact value of signed char?
Anonymous said:
8 years ago
There is no variable name for float in member function definition.
Nam said:
8 years ago
The char type can be both signed (from -128 to 127) or unsigned (0 to 255), it is depended on the concrete C++ implementation. So the answer -61 is not always true.
See "The C++ Programming Language, 4th edition" by Bjarne Stroustrup, section 6.2.3.
See "The C++ Programming Language, 4th edition" by Bjarne Stroustrup, section 6.2.3.
Sai theja said:
8 years ago
@Aks.
Why A value is taken as 65?
Why A value is taken as 65?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers