Understanding the Evaluation Order of an X Variable in C Programming

  • Thread starter Thread starter porums
  • Start date Start date
  • Tags Tags
    Variable
AI Thread Summary
The discussion clarifies that the provided code is written in C++, not C. It emphasizes that statements in C++ are evaluated in the order they appear, meaning the calculation for y1 (6*x) is evaluated before y2 (5*x). For those uncertain about code evaluation, using a debugger with compilation symbols is recommended, as it allows users to step through the code and observe the evaluation of each line and variable.
porums
Messages
27
Reaction score
0
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:
 
Technology news on Phys.org
porums said:
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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top