I am beginner in c++ programing I got this question in my university exams and have no idea why the output is like that, the question goes like this What is the output of the following code?
#define SQUARE(x) x*x
inline float square(float y){
return y*y;
}
void main( ){
float a = 0.5,b = 0.5, c, d;
c = SQUARE(++a);
d = square(++b);
}
The question itself does not have any cin or cout statement to display any output in the console screen so here is altered code
#include<iostream>
#define SQUARE(x)x*x
using namespace std;
inline float square(float y){
return y*y;
}
int main(){
float a = 0.5,b=0.5,c,d;
c=SQUARE(++a);
d = square(++b);
cout<<c<<endl<<d;
}
And the output for the above code is 6.25 2.25 why the output isn't is 2.25 and 2.25 instead it is 6.25 and 1.25?