C Language | 10 Minute‐Test 18


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.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        printf("%d ", 1);

        goto l1;

        printf("%d ", 2);

        l1:goto l2;

        printf("%d ", 3);

        l2:printf("%d ", 4);

   }

 

A.
1 4
B.
Compile time error
C.
1 2 4
D.
1 3 4

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

2.

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

A.
for (i = n; i>0; i-)
B.
for (i = n; i >= 0; i-)
C.
for (i = n-1; i>0; i-)
D.
for (i = n-1; i>-1; i-)

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

3.

Which keyword can be used for coming out of recursion?

A.
break
B.
return
C.
exit
D.
Both (a) and (b)

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

4.

What linkage does automatic variables have?

A.
Internal linkage
B.
External linkage
C.
No linkage
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

5.

Which of the following is a User-defined data type?

A.
typedef int Boolean;
B.
typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
C.
struct {char name[10], int age};
D.
all of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

typedef and struct are used to define user-defined data types.

6.

Comment on the output of this C code?

    #include <stdio.h>

    int main()

    {

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

        int i;

        for (i = 0; i < 5; i++)

            if ((char)a[i] == '5')

                printf("%d\n", a[i]);

            else

                printf("FAIL\n");

    }

 

A.
The compiler will flag an error
B.
Program will compile and print the output 5
C.
Program will compile and print FAIL for 5 times
D.
Program will compile and print the ASCII value of 5

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

7.

Comment on the output of this C code?

    #include  <stdio.h>

    int main()

    {

        char c;

        int i = 0;

        FILE *file;

        file = fopen("test.txt", "w+");

        fprintf(file, "%c", 'a');

        fprintf(file, "%c", -1);

        fprintf(file, "%c", 'b');

        fclose(file);

        file = fopen("test.txt", "r");

        while ((c = fgetc(file)) !=  -1)

            printf("%c", c);

        return 0;

    }

 

A.
a
B.
Infinite loop
C.
Depends on what fgetc returns
D.
Depends on the compiler

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

8.

To declare a 3 dimension array using pointers, which of the following is the correct syntax:

A.
char *a[][];
B.
char **a[];
C.
char ***a;
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

9.

Comment on the output of this C code?

    #include <stdio.h>

    int main()

    {

        char *a = {"p", "r", "o", "g", "r", "a", "m"};

        printf("%s", a);

    }

 

A.
Output will be program
B.
Output will be p
C.
No output
D.
Compile-time error

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

10.

What is the output of this C code?

    #include <stdio.h>

    void main()

    {

        double b = 5 & 3 && 4 || 5 | 6;

        printf("%lf", b);

    }

 

A.
1.000000
B.
0.000000
C.
7.000000
D.
2.000000
Submit your test now to view the Results and Statistics with answer explanation.