MCQ

100 Multiple Choice Questions In C Programming – Part 1

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

1. A preprocessor directive is a statement that begins with_____

A {

B #

C //

D /*

B
The preprocessor is a program executed during the first stage of compilation. It performs textual modifications on the source file from directives. The different preprocessor directives, introduced by the # character, are designed to :

  • Incorporation of source files (#include),
  • Definition of symbolic constants and macros (#define),
  • Conditional compilation (#if, #ifdef,…).


 

 

 

2. Which character always ends a statement?

A ,

B .

C }

D ;

D
; always used to end a statement. Example:

printf("Hello, World!");

 

 
 

3. How to write a comment on a single line?

A /* my comment

B // my comment //

C // my comment

D /* my comment */

B, C, D
If your comment is short, you should use a double slash (//) followed by your comment. For example:

// this is a comment

If your comment is long, type your comment between (/* and */). For example:

/* this is a 
multi-line 
comment */

 

 

4. What is a library?

A A source file already written containing ready-made functions

B A file allowing to display text on the screen

C A file containing my program

D None of the above

A
A library is a source file already written containing ready-made functions.

 

 

5. What is the name of the main function of a C program?

A principal

B main

C any name

D begin

B
The name of the main function of a C program is ‘main()’. The main function is the most important function in C programs: it is mandatory in all programs. The execution of a program automatically calls the main function. Example:

#include <stdio.h>

int main() 
{
   printf("Hello, World!");
   return 0;
}

 

 

6. Which of the following functions display “Hello, World!” on the screen in console mode?

A echo("Hello, World!");

B print("Hello, World!");

C printf("Hello, World!");

D show("Hello, World!");

C
printf function allow us to display a text on the screen in console mode. Example:

#include <stdio.h>

int main() 
{
   printf("Hello, World!");
   return 0;
}

Output:

Hello, World!

 

 
 

7. Which of the following characters is used to make a line break on the screen?

A \t

B \a

C \r

D \n

D
\n character is used to make a line break on the screen. Example:

#include <stdio.h>

int main() 
{
   printf("Hello,\n World!");
   return 0;
}

Output:

Hello,
 World!

 

 

8. Which of the following characters returns the cursor to the left of the screen?

A \t

B \a

C \r

D \n

C
\r character is used to move the cursor or print head to the beginning of the current line. Example:

#include <stdio.h>

int main() 
{
   printf("Hello,\r World!");
   return 0;
}

Output:

 World!

 

 

9. What kind of files can be created with C programming?

A Images (*.jpg, *.png, *.gif…)

B Executables (*.exe on Windows)

C Sources (*.c)

D Text files (*.txt)

C
Files with the .C extension contain the source code in text format for programs, functions and objects in C or C++.

 

 
 

10. The program that translates your code from a high-level language to the binary language is called ________

A programmer

B compiler

C translator

D linker

B
Compiler is a program that translates the entire source code of a software project into machine code before it is executed.

 

 

 
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 *