I am a novice to computer C programming,
here the progrm:
int main()
{
int x;
cin>>x;
int y1=6*x; //[1]
int y2=5*x; //[2]
cout<<y1<<y2;
}
which [1] or [2] is evaluated first or equally evaluatd at the same time? :confused:
shoehorn
Aug22-08, 08:40 AM
I am a novice to computer C programming,
here the progrm:
int main()
{
int x;
cin>>x;
int y1=6*x; //[1]
int y2=5*x; //[2]
cout<<y1<<y2;
}
which [1] or [2] is evaluated first or equally evaluatd at the same time? :confused:
Firstly, that's C++ code, not C code.
Secondly, statements are typically evaluated in the order in which they appear. As a result, the statement defining the variable y1 is evaluated before that which defines y2.
More broadly speaking, if you ever find yourself confused about the evaluation of code, try compiling the code with debugging symbols. You can then step the code through a debugger and watch how each line is evaluated by displaying the variables.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.