3
Q:

Output of the Program :

main()

{

int i = 1;

while (i <= 5)

    {

         printf( "%d", i );

         if (i > 2) goto here;

         i++;

     }

}

fun()

{

here : printf( "PP" );

}

A) 1 B) 2
C) Compilation error D) Exception occurs

Answer:   C) Compilation error



Explanation:

Compiler error: Undefined label 'here' in function main

Subject: Programming
Q:

What is the output of this C code?

   #include <stdio.h>
    int main()
    {
        int a = 1, b = 1;
        switch (a)
        {
        case a*b:
            printf("yes ");
        case a-b:
            printf("non");
            break;
        }
    }

A) yes B) no
C) Compile time error D) yes no
 
Answer & Explanation Answer: C) Compile time error

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

7 18725
Q:

What is the output of this C code?

        #include <stdio.h>
        void main()
        {
            int x = 97;
            char y = x;
            printf("%cn", y);
        }

A) a B) 97
C) Run time error D) None
 
Answer & Explanation Answer: A) a

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

1 11932
Q:

What is the output of this C code?

        #include <stdio.h>
        void main()
        {
            int y = 3;
            int x = 5 % 2 * 3 / 2;
            printf("Value of x is %d", x);
        }

A) Value of x is 1 B) Value of x is 2
C) Value of x is 3 D) Compile time error
 
Answer & Explanation Answer: A) Value of x is 1

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

2 10471
Q:

What is the output of this C code?

       #include <stdio.h>
        void main()
        {
            int x = 1, z = 3;
            int y = x << 3;
            printf( "%dn", y );
        }

A) -2147483648 B) -1
C) Run time error D) 8
 
Answer & Explanation Answer: D) 8

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

2 14681
Q:

main()

{

char *p; p = "Hello";

printf ("%cn", *&*p);

}

A) H B) Hello
C) Compilation error D) H E L L O
 
Answer & Explanation Answer: A) H

Explanation:

* is a dereference operator & is a reference operator. They can be applied any number of times provided it is meaningful. Here p points to the first character in the string "Hello". *p dereferences it and so its value is H. Again & references it to an address and * dereferences it to the value H

Report Error

View Answer Report Error Discuss

Filed Under: Programming
Job Role: Software Architect

19 30524
Q:

void main()

{

char good *better, *best;

printf( "%d..%d", sizeof(better), sizeof(best) );

}

A) 1..2 B) 4..4
C) 4..2 D) 2..2
 
Answer & Explanation Answer: C) 4..2

Explanation:

The second pointer is of char type and not a good pointer.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

4 11959
Q:

enum colors {BLACK,BLUE,GREEN}

main()

{

printf( "%d..%d..%d", BLACK, BLUE, GREEN );

return(1);

}

A) 1..2..3 B) 0..1..2
C) 1..1..1 D) 0..0..0
 
Answer & Explanation Answer: B) 0..1..2

Explanation:

enum assigns numbers starting from 0, if not explicitly defined.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

8 19137
Q:

#define clrscr() 100

main()

{

clrscr();

printf( "%dn", clrscr() );

}

A) 100 B) 0
C) Compilation error D) Exception occurs
 
Answer & Explanation Answer: A) 100

Explanation:

Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs.The input program to compiler looks like this :

main ()

{

100;

printf("%d\n",100);

}

Note: 100; is an executable statement but with no action. So it doesn't give any problem.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

13 22886