MCQ

100 Multiple Choice Questions In C Programming – Part 7

This collection of 100 Multiple Choice Questions and Answers (MCQs) In C Programming : Quizzes & Practice Tests with Answer focuses on “C Programming”.
 

1. Which of these variable types matches a pointer?

A int

B float *

C long

D char

B
A pointer is an object (Lvalue) whose value is equal to the address of another object. A pointer is declared by the following instruction:

type *pointer-name;

Where type is the type of the pointed object. This declaration declares an identifier, ‘pointer-name’, associated with an object whose value is the address of another object. The identifier ‘pointer-name’ is an address identifier. As for any Lvalue, its value is modifiable.

 

 

2. What is the output of the following C program?
#include <stdio.h>

void main()
{
     float a = 0.2;
     printf("%d, ", a);
     printf("%f", a);
}

A 0, 0.999999

B 0, 0.200000

C Junk value, 0.200000

D 0.200000, junk value

C
The %d identifier is used for integer numbers, that’s why it displays Junk value.

Output:

-1558040520, 0.200000

 

 
 

3. In which order does the compilation occur?

A Preprocessor – Compiler – Linker

B Compiler – Linker – Preprocessor

C Linker – Preprocessor – Compiler

D Preprocessor – Linker – Compiler

A
  • The preprocessor starts the work by replacing each #include directive with the contents of the requested file and by running conditional tests to enable or disable some pieces of code.
  • The compiler instantiates the templates, executes the constexpr functions, checks the quality of our code and then, in several phases, transforms the C code into an object file.
  • The linker links several object files to resolve missing symbols and complete the compilation process by generating a working executable.

 

 

 

4. What is the output of the following C program?
#include <stdio.h>

void main()
{
     double a = 14728749.22;
     int b = a;
     printf("%d\n", b);
     printf("%lf\n", b);
}

A 1472874, 0.000000

B 1472874, 1472874.0

C 14728749, 14728749.22

D 0, 0.0

A

 

 

5. What is the output of the following C program?
#include <stdio.h>

void main()
{
     int a = 97;
     char b = a;
     printf("%c\n", b);
}

A 97

B b

C a

D Depends on compiler

C
The ASCII code for “a” is 97.

 

 
 

6. When a double is converted to a float, its value is _____?

A Rounded

B Truncated

C Depends on compiler

D Depends on the standard

C

 

 

7. What does the following code give: &A ?

A The address of the variable A

B The value of the variable A

C The value of the variable to which A points

D None of the above

A
&A gives the address of the variable A.

 

 

8. What is the output of the following C program?
#include <stdio.h>

int main()
{
     int i = 15;
     char c = -15;
     if (i < c)
         printf("15 < -15\n");
     else
         printf("15 > -15\n");
}

A 15 < -15

B 15 > -15

C Depends on compiler

D Depends on the standard

B
Whenever you have an operator like (+ – * / % << >> & | ^ == != < <= > >=) between two operands of different types, the two types are converted to a common type before the operation is performed.

 

 
 

9. What does the following code give: *A ?

A The address of the variable A

B The value of the variable A

C The value of the variable to which A points

D None of the above

C
*A gives the value of the variable to which A points.
 

 

 

10. What is the output of the following C program?
#include <stdio.h>

void main()
{
    int x = 1, y = 0, z = 5;
    int a = x && y || z++;
    printf("%d", z);
}

A 0

B 5

C 6

D Other

C
z was incremented at line 6.

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *