• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Loops & Control Structure

Question 41

Consider the following pseudocode: 
 

x:=1;
i:=1;
while (x ? 500)
begin
x:=2x ;
i:=i+1;
end


What is the value of i at the end of the pseudocode?
 

  • 4
     

  • 5
     

  • 6
     

  • 7
     

Question 42

In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other.
 

  • Loop unrolling
     

  • Strength reduction
     

  • Loop concatenation
     

  • Loop jamming
     

Question 43

How many lines of output does the following C code produce? 
 

C
#include<stdio.h>
float i=2.0;
float j=1.0;
float sum = 0.0;
main()
{
    while (i/j > 0.001)
    {
        j+=j;
        sum=sum+(i/j);
        printf(\"%f\\n\", sum);
    }
}
  • 8
     

  • 9
     

  • 10
     

  • 11
     

Question 44

C
#include <stdio.h>

int main()
{
    unsigned int i = 65000;
    while (i++ != 0);
    printf(\"%d\", i);
    return 0;
}
  • Infinite Loop
     

  • 0
     


  •  

  • Run Time Error
     

Question 45

Consider the C program below. 
 

C
#include <stdio.h>
int *A, stkTop;
int stkFunc (int opcode, int val)
{
    static int size=0, stkTop=0;
    switch (opcode)
    {
    case -1:
        size = val;
        break;
    case 0:
        if (stkTop < size ) A[stkTop++]=val;
        break;
    default:
        if (stkTop) return A[--stkTop];
    }
    return -1;
}
int main()
{
    int B[20];
    A=B;
    stkTop = -1;
    stkFunc (-1, 10);
    stkFunc (0, 5);
    stkFunc (0, 10);
    printf (\"%d\\n\", stkFunc(1, 0)+ stkFunc(1, 0));
}

The value printed by the above program is ___________
 

  • 9
     

  • 10
     

  • 15
     

  • 17
     

There are 45 questions to complete.

Last Updated :
Take a part in the ongoing discussion