Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

C PROGRAM QUESTIONS : PART 8

What is the output of this C code?
    void main()
    {
       int i = 0;
       for (i = 0;i < 5; i++)
            if (i < 4)
           {
             printf("Hello");
               break;
            }
    }

Hello is printed 5 times
Hello is printed 4 times
 Hello 
Hello is printed 3 times
SHOW ANSWER

What is the output of this C code?
    void main()
    {
        int i = 0;
        if (i == 0)
        {
            printf("Hello");
            continue;
       }
    }

Hello is printed infinite times 
Hello 
varies 
Compile time error
SHOW ANSWER

What is the output of this C code?
    void main()
    {
       int i = 0;
        if (i == 0)
        {
          printf("Hello");
           break;
        }
    }

Hello is printed infinite times
Hello
 varies 
 compile time error
SHOW ANSWER

What is the output of this C code?
    int main()
    {
        int i = 0;
        do
        {
            i++;
           if (i == 2)
                continue;
               printf("In while loop ");
        } while (i < 2);
       printf("%d\n", i);
   }

In while loop 2 
In while loop In while loop 3
 In while loop 3 
Infinite loop
SHOW ANSWER

What is the output of this C code?
    int main()
    {
        int i = 0, j = 0;
        for (i; i < 2; i++){
            for (j = 0; j < 3; j++){
                printf("1\n");
                break;
            }
            printf("2\n");
        }
      printf("after loop\n");
    }

1     2     after loop 
 1     after loop 
1     2     1     2     after loop 
1     1     2     after loop
SHOW ANSWER

What is the output of this C code?
    int main()
    {
        int i = 0;
        while (i < 2)
        {
            if (i == 1)
                break;
                i++;
                if (i == 1)
                    continue;
                    printf("In while loop\n");
        }
        printf("After loop\n");
   }

In while loop     After loop
After loop 
In while loop     In while loop     After loop 
In while loop
SHOW ANSWER

What is the output of this C code?
    int main()
    {
        int i = 0;
        char c = 'a';
        while (i < 2){
            i++;
            switch (c) {
           case 'a':
                printf("%c ", c);
                break;
                break;
            }
        }
        printf("after loop\n");
   }

a after loop
a a after loop
after loop 
 None of the mentioned
SHOW ANSWER

What is the output of this C code?
    int main()
    {
        printf("before continue ");
        continue;
        printf("after continue\n");
    }

Before continue after continue 
 Before continue 
after continue 
 Compile time error
SHOW ANSWER

The following code ‘for(;;)’ represents an infinite loop. It can be terminated by.

break 
exit(0) 
abort() 
 All of the mentioned
SHOW ANSWER

The correct syntax for running two variable for loop simultaneously is.

for (i = 0; i < n; i++)      for (j = 0; j < n; j += 5)
 for (i = 0, j = 0;i < n, j < n; i++, j += 5) 
 for (i = 0; i < n;i++){}     for (j = 0; j < n;j += 5){} 
None of the mentioned
SHOW ANSWER

Which for loop has range of similar indexes of 'i' used in for (i = 0;i < n; i++)?

for (i = n; i>0; i–) 
for (i = n; i>=0; i–) 
 for (i = n-1; i>0; i–) 
 for (i = n-1; i>-1; i–)
SHOW ANSWER

Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3) ?

Variable 
 Function 
 typedef 
macros
SHOW ANSWER

What is the output of this C code?
    int main()
    {
        short i;
        for (i = 1; i >= 0; i++)
            printf("%d\n", i);
    }

The control won’t fall into the for loop
Numbers will be displayed until the signed limit of short and throw a runtime error 
 Numbers will be displayed until the signed limit of short and program will successfully terminate 
This program will get into an infinite loop and keep printing numbers with no errors
SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in