Loops & Control Structure in C

31. How many times letsfindcourse will be printed?

#include <stdio.h>
int main()
{
    int i = -5;
    while (i <= 5)
    {
        if (i >= 0)
            break;
        else
        {
            i += 1;
            continue;
        }
        printf("letsfindcourse");
    }
    return 0;
}

A. 5 times
B. 10 times
C. 0 times
D. Infinite times

View Answer


32. What is the output of this program?

#include <stdio.h>
void main()
{
    int a = 3;
    while (a--)
    {
        int a = 10;
        a--;
        printf("%d ", a);
    }
}

A. 9 9 9
B. 9 8 7
C. 2 1 0
D. Infinite loop

View Answer


33. Which of the given statment is true about the given code ?

int main()
{
 int i = 0;
 for ( ; i < 5 ; )
 { 
   if (i < 5)
     printf("Hello", i++);
   else
     continue;
   printf("World");
 }
 return 0;
}

A. It will print hello 5 times followed by World one time
B. It will print helloWorld 5 times
C. It will print helloWorld infinite times
D. Compilation Error

View Answer


34. How many times value of j is checked in the below code ?

#include 
    int main()
    {
        int j = 0;
        do {
            j++;
            printf("");
        } while (j < 5);
    }

A. 3
B. 4
C. 5
D. 1

View Answer


35. What is the output of the following code?

int main()
{
    int i = 0;
    switch(i)
    {
    case 0 : i++;
    case 1 : i+++2;
    case 2 : ++i;
    }
    pritnf("%d",i++);

    return 0;
}

A. 2
B. 3
C. 4
D. 5

View Answer


36. How many x are printed?

    for(i=0,j=10;i < j;i++,j--) 
        printf("x");

A. 10
B. 5
C. 4
D. 6

View Answer


37. How many x are printed?

    for(i=-2,j=5;i < j;i++,j--) 
        printf("x");

A. 10
B. 5
C. 4
D. 6

View Answer


38. What will be the output of the program?

 int a=0,b=2;
 if(a=0) b=0;
 else b*=10;

A. 0
B. 20
C. 2
D. None of the above

View Answer


39. What will be the output of the program?

 int a=2,b=2;
 if(a!=0) 
    b=0;
 else 
    b*=10;
 printf("%d",b);

A. 0
B. 20
C. 2
D. None of the above

View Answer


40. What will be the output of the program?

 int a=2,b=2;
 if(a && 0) 
     b=0;
 else 
     b*=10;
  printf("%d",b);

A. 0
B. 20
C. 2
D. None of the above

View Answer







Also check :


Discussion


* You must be logged in to add comment.