edited by
719 views
7 votes
7 votes


Trace the execution of the following if statements and select the output from this code fragment


int main()
{
    int a = 3, b = 7 ;
    if ( (a + b) % 2 != 0 ) {
        printf("tetrahedron\n");
    } 
    else if ( a > b ) {
        printf("cube\n");
    } 
    else if ( b - 4 > a ) {
        printf("octahedron\n");
    }
    else {
        printf("dodecahedron\n");
    }
}
  1. Tetrahedron
  2. Cube
  3. Octahedron
  4. Dodecahedron
edited by

2 Answers

1 votes
1 votes
dodecahedron will be printed since all if conditions will evaluate to false.
0 votes
0 votes

DODECAHEDRON will be printed because others condition will results to FALSE.

Answer:

Related questions