Which if any of the following C statements contain variables

Which, if any of the following C statements contain variables whose values are replaced? Identify the variables being replaced with a new value. scanf (\"%d %d\", & num1, &num2;); p = j + k + 3 * 0; printf(\"%d\", & new value); scanf (\"%d\", newvalue); printf(\"a = 7\");

Solution

a. scanf(\"%d%d\", &num1, &num2);   //This statement reads two values from console, and will be stored in num1, and num2.
                               //So, the variables being replaced with new value are, num1, and num2.
b. p = j + k + 3 * 0;       //This statement evaluates the expression on the right hand side, and will store the result in p.
                           //So, the variables being replaced with new value is p.
c. printf(\"%d\", &newvalue);   //This prints the address of the variable newvalue. So, no variable will be modified/replaced.

d. scanf(\"%d\", newvalue);   //If newvalue is declared as an integer pointer, will store the value read into newvalue.
                           //Otherwise will return an error.
e. printf(\"a = 7\");       //Prints the string to console, and no variable will be modified.
                       //Note that, \"a = 7\" is a string, and is not an assignment, and has no effect on variable a.

 Which, if any of the following C statements contain variables whose values are replaced? Identify the variables being replaced with a new value. scanf (\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site