C Language | 10 Minute‐Test 6


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

Which of the following are generated from char pointer?

A.
char *string = “Hello.”;
B.
char *string;
scanf(“%s”, string);
C.
char string[] = “Hello.”;
D.
Both (a) and (c).

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

2.

Comment on the output of this C code?

#include <stdio.h>

   int main()

   {

       int a = 1;

       switch (a)

       {

       case a:

           printf("Case A ");

       default:

           printf("Default");

       }

   }

 

A.
Output: Case A
B.
Output: Default
C.
Output: Case A Default
D.
Compile time error

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

3.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = -2;

       if (!0 == 1)

           printf("yes\n");

       else

           printf("no\n");

   }

 

A.
yes
B.
no
C.
Run time error
D.
Undefined

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

4.

functions can return structure in c?

A.
true
B.
false
C.
Depends on the compiler
D.
Depends on the standard

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

5.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       float x = 'a';

       printf("%f", x);

       return 0;

   }

 

A.
a
B.
run time error
C.
a.0000000
D.
97.000000

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Since the ASCII value of a is 97, the same is assigned to the float variable and printed.

6.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = 3; //, y = 2;

       const int *p = &x;

       *p++;

       printf("%d\n", *p);

   }

 

A.
Increment of read-only location compile error
B.
4
C.
Some garbage value
D.
Undefined behaviour

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

7.

What is the output of the code given below?

#include <stdio.h>

   int main()

   {

       int i = 0, j = 0;

       l1: while (i < 2)

       {

           i++;

           while (j < 3)

           {

               printf("loop\n");

               goto l1;

           }

       }

   }

 

A.
loop loop
B.
compilation error
C.
loop loop loop loop
D.
infinite loop

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Size of any type of pointer is 4 on a 32-bit machine.

8.

Which of the following file extensions are accepted with #include?

A.
.h
B.
.in
C.
.com
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The preprocessor will include whatever file extension you specify in your #include statement. However, it is not a good practice as another person debugging it will find it difficulty in finding files you have included.

9.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        int a[4] = {1, 2, 3, 4};

        int *p = &a[1];

        int *ptr = &a[2];

        ptr = ptr * 1;

        printf("%d\n", *ptr);

    }

 

A.
2
B.
1
C.
Compile time error
D.
Undefined behaviour

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

10.

Which is false?

A.
Constant variables need not be defined as they are declared and can be defined later
B.
Global constant variables are initialised to zero
C.
const keyword is used to define constant values
D.
You cannot reassign a value to a constant variable

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Since the constant variable has to be declared and defined at the same time, not doing it results in an error. Hence the statement a is false.


Submit your test now to view the Results and Statistics with answer explanation.