C++ Programming - Functions - Discussion
Discussion Forum : Functions - Programs (Q.No. 13)
13.
Which of the following statement is correct about the program given below?
#include<iostream.h>
void Tester(float xx, float yy = 5.0);
class IndiaBix
{
float x;
float y;
public:
void Tester(float xx, float yy = 5.0)
{
x = xx;
y = yy;
cout<< ++x % --y;
}
};
int main()
{
IndiaBix objBix;
objBix.Tester(5.0, 5.0);
return 0;
}
Discussion:
10 comments Page 1 of 1.
Raavana said:
7 years ago
It's double function used over there & we cannot use % for floating numbers.
We have to use fmod() function for using it for floating number.
We have to use fmod() function for using it for floating number.
(5)
Kukku said:
8 years ago
@Divya.
For taking float we initialize like dis float a = 5.0f.
And for double we simply initialize,
float a =5.0 compiler will treat it automatically double.
For taking float we initialize like dis float a = 5.0f.
And for double we simply initialize,
float a =5.0 compiler will treat it automatically double.
Divya said:
8 years ago
Why it is taking double? It's float only.
Please, can anyone explain me?
Please, can anyone explain me?
Cnu@yalamuri said:
9 years ago
% is used for integers and fmod is used for float values.
(2)
Sanjay said:
10 years ago
What is the range for float?
Ravi said:
1 decade ago
Read @Himanshu's comment.
Dixit said:
1 decade ago
We cannot use % on floats!
Bittoo said:
1 decade ago
We cannot use % operator for floating-point numbers.
If you want perform mod on floating-point numbers, then go for fmod() function.
If you want perform mod on floating-point numbers, then go for fmod() function.
Himanshu said:
1 decade ago
We have to use fmod() function for modulus operator to print float value. that's why it will report compile time error.
(2)
Saurabh said:
1 decade ago
Because 5.0 will be taken as double not float
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers