Confusing, can someone give an example of how increments and decrements are used?
x++ uses x value than increase it. ++x increase x than use the increased value. Example: var x = 1; // ++x increase x to 2 , y = 2+2 , then ++ increase x to 3. var y = ++x + x++; // 5 3 will alerted cause ++y increase y to 5 but x++ increase x to 4 after alert alert(++y+' '+x++)
increment does the operation/assignment before outputing. var x = 1 ; alert(++x); //this will output 2. decrement does the operation/assignment after outputing. var x = 1; alert(x++) ; // this will output 1, just after this the value of x will be 2.
Problem Statement Given two integers a and b, your task is to calculate and print the following four values:
Please help, any idea?
Завершение процесса, код 3