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 9

What is the output of this C code?
    void main()
    {
        double k = 0;
        for (k = 0.0; k < 3.0; k++)
            printf("Hello");
    }

Run time error 
 Hello is printed thrice 
Hello is printed twice 
Hello is printed infinitely
SHOW ANSWER

What is the output of this C code?
   void main()
    {
        double k = 0;
        for (k = 0.0; k < 3.0; k++);
            printf("%lf", k);
   }

2.000000
4.000000 
3.000000 
 Run time error
SHOW ANSWER

What is the output of this C code?
    void main()
    {
       int k;
        for (k = -3; k < -5; k++)
            printf("Hello");
    }

Hello 
Infinite hello 
Run time error 
Nothing
SHOW ANSWER

What is the output of this C code?
  int main()
    {
        int i = 0;
        for (; ; ;)
            printf("In for loop\n");
          printf("After loop\n");
    }

Compile time error 
 Infinite loop 
 After loop 
Undefined behaviour
SHOW ANSWER

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

In for loop after loop 
 After loop 
Compile time error 
Undefined behaviour
SHOW ANSWER

What is the output of this C code?
    int main()
    {
        int *p = NULL;
        for (foo(); p; p = 0)
            printf("In for loop\n");
            printf("After loop\n");
    }

In for loop after loop 
Compile time error 
 Infinite loop 
 Depends on the value of NULL
SHOW ANSWER

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

Compile time error 
 In for loop 
Depends on the standard compiler implements 
Depends on the compiler
SHOW ANSWER

What is the output of the code given below?
   int main()
    {
       printf("%d ", 1);
        goto l1;
       printf("%d ", 2);
       l1:goto l2;
        printf("%d ", 3);
        l2:printf("%d ", 4);
   }

1   4 
Compilation error 
1   2   4 
1   3   4
SHOW ANSWER

What is the output of code given below?
    int main()
    {
        printf("%d ", 1);
        l1:l2:
        printf("%d ", 2);
        printf("%d\n", 3);
    }

Compilation error 
1   2   3 
 1  2 
 1  3
SHOW ANSWER

What is the output of code given below?
    int main()
    {
       printf("%d ", 1);
        goto l1;
        printf("%d ", 2);
    }
    void foo()
   {
        l1 : printf("3 ", 3);
    }

1  2  3 
1  3 
1  3  2 
 Compilation error
SHOW ANSWER

What is output of code given below?
    int main()
    {
        int i = 0, j = 0;
       while (i < 2)
        {
            l1 : i++;
           while (j < 3)
            {
                printf("Loop\n");
                goto l1;
            }
        }
    }

Loop Loop 
 Compilation error 
 Loop  Loop  Loop  Loop 
Infinite Loop
SHOW ANSWER

What is the output of code given below?
    int main()
    {
        int i = 0, j = 0;
        while (l1: i < 2)
        {
            i++;
            while (j < 3)
            {
                printf("loop\n");
                goto l1;
            }
        }
    }

loop  loop 
Compilation error 
loop  loop  loop  loop 
 Infinite loop
SHOW ANSWER

What is the output of the code given below?
    int main()
    {
        int i = 0, j = 0;
        l1: while (i < 2)
        {
            i++;
            while (j < 3)
            {
              printf("loop\n");
                goto l1;
            }
        }
    }

loop  loop 
 compilation error 
 loop  loop  loop  loop 
infinite loop
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