Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1-What would be printed from the following program segment: for (x = 12 ; x = 0

ID: 658888 • Letter: 1

Question

1-What would be printed from the following program segment:
    for (x = 12 ; x = 0 ; x = x - 2)
          printf ("%d ", x);
       a)on the same line: 12 10 8 6 4 2 0
b)       on the same line: 12 11 10 9 8 7 6 5 4 3 2 1 0
       C) on the same line: 12 10 8 6 4 2
D) on separate lines: 12 10 8 6 4 2 0
________________
2-
What would be printed from the following program segment :
x = 11 ;
do
    {   printf ("%d ", x ) ;
        x-- ;
    }   while (x < 7) ;
       a)11
       b) On separate lines: 11 10   9   8
       c) On same line: 11   10   9   8
       d) 10
__________________________-
3)If x = 4, y = 0, z = 2, what is the value of x, y, and z after executing the following code fragment?
if ( x && y )
        x = 3 ;
   else
        y = 2 ;
       a) x = 4, y = 2, z = 2
       b) x = 3, y = 0, z = 2
       c) x = 3, y = 0, z = 2
       d) x = 4, y = 0, z = 0
________________-
4)The character classification functions are found in the standard library (stdlib.h).
True
False
5)The expression   ! ( ! ( x > y ) ) is equivalent to ( x > y )
True
False

Explanation / Answer

1. Compilation fails because the for loopaccepting only one initialization, condition ,increment/decrement

see the syntax for(initialization; condition; increment/decrement){

                               // Stmts to execute;

                          }

for (x = 12 ; x <= 0 ; x = x - 2) it gives the out put as foloows: a)on the same line: 12 10 8 6 4 2 0

2. b) On separate lines: 11 10   9   8

do -while is a exit control loop

he do while construct consists of a process symbol and a condition. First, the code within the block is executed, and then the condition is evaluated. If the condition is true the code within the block is executed again. This repeats until the condition becomes false. Because do while loops check the condition after the block is executed, the control structure is often also known as a post-test loop. Contrast with the while loop, which tests the condition before the code within the block is executed.The do-while loop is an exit-condition loop. This means that the code must always be executed first and then the expression or test condition is evaluated. If it is true, the code executes the body of the loop again. This process is repeated as long as the expression evaluates to true. If the expression is false, the loop terminates and control transfers to the statement following the do-while loop.

3. if (condition) {

stmt;

}else {

stmt;

}

the above is the basicsyntax ofthe if else

4. C character classification is an operation provided by a group of functions in the ANSI C Standard Library for the C programming language. These functions are used to test characters for membership in a particular class of characters, such as alphabetic characters, control characters, etc. Both single-byte, and wide characters are supported.

Ans False

5. True

<stdlib.h> Defines numeric conversion functions, pseudo-random numbers generation functions, memory allocation, process control functions