Skip to main content

MCQ Questions | Advanced C programming

MCQ on Advanced C programming

Explore most important multiple choice Questions on advanced c programming. Here is the chapterwise MCQ for study.

Table of contents
MCQ on Preprocessors
MCQ on pointers
MCQ on strings
MCQ on structure
MCQ on advanced c features
MCQ on file handling
MCQ type Questions on Preprocessors in C

Q1 : What are the types of C Preprocessor Directives ?

  1. Macros
  2. Conditional Compilation
  3. File Inclusion
  4. All the above

Answer : All of the above

Q2 : Processor Directive in C language starts with?

  1. $
  2. @
  3. &
  4. #

Answer : #

Q3 : What is the keyword used to define a C macro ?

  1. def
  2. definition
  3. define
  4. defy

Answer : define

Q4 : What is the C keyword used to create global Constants?

  1. const
  2. definition
  3. def
  4. define

Answer : const

Q5 : What does #include stdio.h in c language ?

  1. It includes stdio.h into existing C program.
  2. #include increases the size of C program by including the specified file contents like functions, constants etc.
  3. #include includes specified file before compilation.
  4. All the above

Answer : All the above

Q6 : #include is called

  1. Preprocessor directive
  2. Inclusion directive
  3. File inclusion directive
  4. All of the mentioned

Answer : Preprocessor directive

Q7 : The preprocessor provides the ability for _______________.

  1. The inclusion of header files
  2. The inclusion of macro expansions
  3. Conditional compilation and line control.
  4. All of the mentioned

Answer : All of the mentioned

Q8 : The purpose of the preprocessor directive #error is that ____________

  1. It rectifies any error present in the code
  2. It rectifies only the first error which occurs in the code
  3. It causes the preprocessor to report a fatal error
  4. It causes the preprocessor to ignore an error

Answer : It causes the preprocessor to report a fatal error

Q9 : Which of the following is not a preprocessor directive?

  1. #error
  2. #pragma
  3. #if
  4. #ifelse

Answer : #ifelse

MCQ type questions on pointers

Q1 : The reason for using pointers in a C program is ?

  1. Pointers allow different functions to share and modify their local variables.
  2. To pass large structures so that complete copy of the structure can be avoided.
  3. Pointers enable complex “linked” data structures like linked lists and binary trees.
  4. All of the above

Answer : All of the above

Q2 : If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?

  1. .
  2. &
  3. ->
  4. *

Answer : ->

Q3 : A pointer is____

  1. A keyword used to create variables
  2. A variable that stores address of an instruction
  3. A variable that stores address of other variable
  4. All of the above

Answer : A variable that stores address of other variable

Q4 : The operator used to get value at address stored in a pointer variable is___

  1. *
  2. &
  3. &&
  4. ||

Answer : *

Q5 : What is wild pointer?

  1. Pointer which is wild in nature
  2. Pointer which has no value.
  3. Pointer which is not initialized
  4. None

Answer : Pointer which is not initialized

Q6 : Address stored in the pointer variable is of type __________.

  1. Integer
  2. Float
  3. Array
  4. Character

Answer : Integer

Q7 : In order to fetch the address of the variable we write preceding _________ sign before variable

  1. %
  2. ,
  3. &
  4. *

Answer : &

Q8 : Comment on this: const int *ptr;

  1. You cannot change the value pointed by ptr
  2. You cannot change the pointer ptr itself
  3. Both (a) and (b)
  4. You can change the pointer as well as the value pointed by it

Answer : You cannot change the value pointed by ptr

Q9 : “*” is called as ________.

  1. Address operator
  2. Value at operator
  3. Scope resolution operator
  4. None of these

Answer : Value at operator

MCQ questions on strings

Q1 : What is the Format specifier used to print a String or Character array in C printf or scanf function?

  1. %c
  2. %d
  3. %s
  4. %w

Answer : %s

Q2 : What is a String in C Language?

  1. String is a new Data Type in C
  2. String is an array of Characters with null character as the last element of array.
  3. String is an array of Characters with null character as the first element of array
  4. String is an array of Integers with 0 as the last element of array.

Answer : String is an array of characters with null character as the last element of array

Q3 : What is the maximum length of a C String?

  1. 32 characters
  2. 64 characters
  3. 256 characters
  4. None of the above

Answer : None of the above

Q4 : How do you accept a Multi Word Input in C Language?

  1. scanf()
  2. gets()
  3. getc()
  4. finds()

Answer : gets()

Q5 : Which function will you choose to join two words?

  1. strcat()
  2. strcpy()
  3. strncon()
  4. memcon()

Answer : strcat()

Q6 : The______ function returns the number of characters that are present before the terminating null character.

  1. strlength()
  2. strlen()
  3. strlent()
  4. strchr()

Answer : strlen()

Q7 : Which of the following function sets first n characters of a string to a given character?

  1. strinit()
  2. strnset()
  3. strset()
  4. strcset()

Answer : strnset()

Q8 : If the two strings are identical, then strcmp() function returns

  1. -1
  2. 1
  3. 0
  4. Yes

Answer : 0

Q9 : Length of the string "lets find course" is

  1. 14
  2. 15
  3. 16
  4. 17

Answer : 16

Q10 : The ______ character is used to indicate end of string in C programming.

  1. '\0'
  2. \\
  3. "
  4. none of these

Answer : '\0'

Q11 : The string processing related functions are stored in ____________ header file.

  1. stdio.h
  2. conio.h
  3. string.h
  4. none of these

Answer : string.h

Q12 : ______ C string function can be used to search string into given string.

  1. strlen()
  2. strcat()
  3. strstr()
  4. none of these

Answer : strstr()

MCQ questions on structure

Q1 : What is a structure in C language?

  1. A structure is a collection of elements that can be of same data type.
  2. A structure is a collection of elements that can be of different data type.
  3. Elements of a structure are called members.
  4. All the above

Answer : All of the above

Q2 : What is the size of a C structure?

  1. C structure is always 128 bytes.
  2. Size of C structure is the total bytes of all elements of structure.
  3. Size of C structure is the size of largest element.
  4. None of the above

Answer : size of c structure is the total bytes of all elements of structure.

Q3 : Choose a correct statement about C structure elements?

  1. Structure elements are stored on random free memory locations
  2. structure elements are stored in register memory locations
  3. structure elements are stored in contiguous memory locations
  4. None of the above

Answer : structure elements are stored in contiguous memory locations.

Q4 : What are the uses of C Structures?

  1. structure is used to implement Linked Lists, Stack and Queue data structures
  2. Structures are used in Operating System functionality like Display and Input taking.
  3. Structure are used to exchange information with peripherals of PC
  4. All of the above

Answer : All of the above

Q5 : Choose a correct statement about C structures.

  1. A structure can contain same structure type member.
  2. A structure size is limited by only physical memory of that PC.
  3. You can define an unlimited number of members inside a structure.
  4. All of the above

Answer : All of the above

Q6 : Which of the following operation is illegal in structures?

  1. Typecasting of structure
  2. Pointer to a variable of the same structure
  3. Dynamic allocation of memory for structure
  4. All of the mentioned

Typecasting of structure.

Q7 : The correct syntax to access the member of the its structure in the array of structures is? Assuming: struct temp { int b; } s[50];

  1. s.b.[i];
  2. s.[i].b;
  3. s.b[i];
  4. s[i].b;

Answer : s[i].b

Q8 : What is the correct syntax to declare a function foo() which receives an array of structure in function?

  1. void foo(struct *var);
  2. void foo(struct *var[]);
  3. void foo(struct var);
  4. none of the mentioned

Answer : void foo(struct *var);

Q9 : Which of the following are themselves a collection of different data types?

  1. string
  2. structures
  3. char
  4. All of the above

Answer : Structures

Q10 : User-defined data type can be derived by___________

  1. struct
  2. enum
  3. typedef
  4. All of the above

Answer : All of the above

Q11 : Which operator connects the structure name to its member name?

  1. -
  2. <-
  3. .
  4. both 1 and 3

Answer : .

Q12 : Which of the following cannot be a structure member?

  1. Another structure
  2. Function
  3. Array
  4. None of the above

Answer : None of the above

MCQ questions of c advanced features

Q1 : Size of a union is determined by size of the.

  1. First member in the union
  2. Last member in the union
  3. Biggest member in the union
  4. Sum of the sizes of all members

Answer : Biggest member in the union

Q2 : Members of a union are accessed as________________.

  1. union-name.member
  2. union-pointer->member
  3. Both a & b
  4. None of the mentioned

Answer : Both a & b

Q3 : Which of the following share a similarity in syntax? 1. Union, 2. Structure, 3. Arrays and 4. Pointers

  1. 3 and 4
  2. 1 and 2
  3. 1 and 3
  4. 1,3 and 4

Answer : 1 and 2

Q4 : Bit fields can only be declared as part of a structure.

  1. false
  2. true
  3. nothing
  4. varies

Answer : true

Q5 : What is the similarity between a structure, union and enumeration?

  1. All of them let you define new values
  2. All of them let you define new data types
  3. All of them let you define new pointers
  4. All of them let you define new structures

Answer : All of them let you define new data types.

Q6 : Which of the following operators can be applied on structure variables?

  1. Equality comparison ( == )
  2. Assignment ( = )
  3. Both of the above
  4. None of the above

Answer : Assignment ( = )

Q7 : Which of the following reduces the size of a structure?

  1. union
  2. bit-fields
  3. malloc
  4. none of the mentioned

Answer : bit-fields

Q8 : Bit field___

  1. is a field having many sub-fields
  2. is a structure declaring the sizes of the members in terms of bits
  3. is a member of a structure whose size is specified in terms of bits
  4. None of the above

Answer : is a structure of declaring the sizes of the members in terms of bits.

Q9 : The declaration int x : 4; means

  1. x is a four digit integer
  2. x cannot be greater than a four digit integer
  3. x is a four-bit integer
  4. none of the above

Answer : x is four-bit integer

File Handling

Q1 : Which of the following true about FILE *fp

  1. FILE is a keyword in C for representing files and fp is a variable of FILE type.
  2. FILE is a stream
  3. FILE is a buffered stream
  4. FILE is a structure and fp is a pointer to the structure of FILE type

Answer : FILE is a keyword in C for representing files and fp is a variable of FILE type.

Q2 : The first and second arguments of fopen() are

  1. A character string containing the name of the file & the second argument is the mode
  2. A character string containing the name of the user & the second argument is the mode
  3. A character string containing file pointer & the second argument is the mode
  4. None of the mentioned

Answer : A character string containing the name of the file & the second argument is the mode

Q3 : Which type of files can’t be opened using fopen()?

  1. .txt
  2. .bin
  3. .c
  4. None of the above

Answer : None of the above

Q4 : If there is any error while opening a file, fopen will return?

  1. Nothing
  2. EOF
  3. NULL
  4. Depends on compiler

Answer : NULL

Q5 : Select a function which is used to write a string to a file…

  1. pits()
  2. putc()
  3. fputs()
  4. fgets()

Answer : fputs()

Q6 : Which function will return the current file position for stream?

  1. fgetpos()
  2. fseek()
  3. ftell()
  4. fsetpos()

Answer : ftell()

Q7 : What is the need for a File when you can store anything in memory?

  1. Memory (RAM) is limited in any computer.
  2. A file is stored on Hard Disk which can store Gigabytes of data.
  3. File stored on Hard Disk is safe even if PC is switched off. But Memory or RAM contents are cleared when PC is off.
  4. All of the above

Answer : All of the above

Q8 : Where is a file temporarily stored before read or write operation in C language?

  1. Notepad
  2. RAM
  3. Hard disk
  4. Buffer

Answer : Hard disk

Q9 : What are the C functions used to read or write a file in Text Mode?

  1. fprintf(), fscanf()
  2. fread(),fwrite()
  3. fprint(),fscan()
  4. read(),write()

Answer : fprintf(),fscanf()

Comments

Trending⚡

Happy birthday Hardik Pandya | In C programming

  Happy birthday Hardik Pandya . Now you are  28 years old. Great achievement you have. Let's we want to talk more about Hardik pandya. He is great cricketer. Pandya is awesome. In this Blog Post we are going to wish pandya " Happy birthday using C program". Let's tune with us till end. Now we have to wish pandya, so we are going to use printf () function printing message to pandya as " Happy birthday Hardik pandya Now you are 28 years old". Hardik pandya was born on 11 October in 1993. Now we are going to declare a variable called as current_age = 2021 - 1993. It calculate current age Of Hardik pandya. See the "Happy birthday pandya" using c programming. If you liked this Blog Post then don't forget to share with your computer science learning friends. Once again " Happy birthday Hardik Pandya sir". Read also Happy Rakshabandhan wish using C program Friendship day 2021 greetings in C

What is programming explained in simple words

Hi my dear friends today in this blog post we are going to know what programming is? In simple words I will explain to you programming. Nowadays we are watching real life use of programming. How computers learn to speak, talk and do the specified complex task for us. We are all keen to know what is exactly programming? Programming is the process of creating instructions that a computer can understand and execute. These instructions, also known as code, are written in a programming language that is specific to the task at hand. The history of programming can be traced back to the mid-20th century, with the development of the first electronic computers. The first programming languages were known as machine languages, which were specific to a particular type of computer. As computers became more sophisticated, high-level programming languages were developed, such as FORTRAN and COBOL, which were easier for humans to read and write. These languages allow programmers to write code t

check number is prime or odd or even using c program

Here is the c program to check if the user entered number is prime ,even and odd. These few lines of code solve three problems. In the above program we used integer type num variable for storing user entered numbers. Then we used the IF condition statement. That's all. IF condition for even number In the First IF statement we have a logic. If the number is divided by two then the reminder should be 0 then the number is an even number else not an even number. That simple logic is implemented in the first if statement. IF condition for odd number In the second IF statement we Implemented odd number logic. We identify odd numbers just by making little change in even number logic. If the number is divided by two then the reminder should not be a zero. Then the number is odd. That's simple logic used to identify whether a number is odd or not an odd number. IF condition for prime number In the third IF condition we implemented the logic of the prime number. In this IF

Graph Data Structure

Graph A graph can be defined as a group of vertices and edges that are used to connect these vertices. A graph can be seen as a cyclic tree, where the vertices (Nodes) maintain any complex relationship among them instead of having parent child relationship. A graph G can be defined as an ordered set G(V, E) where V(G) represents the set of vertices and E(G) represents the set of edges which are used to connect these vertices. A Graph G(V, E) with 5 vertices (A, B, C, D, E) and six edges ((A,B), (B,C), (C,E), (E,D), (D,B), (D,A)) is shown in the following figure. Directed and undirected graph Graph terminology Graph Representation Directed Graph Adjancency Matrix Graph Traversal Depth first search algorithm Directed and undirected graph A graph can be directed or undirected. However, in an undirected graph, edges are not associated with the directions with them. An undirected graph does not have any edges in directions. If an edge exists between ver

How to write programs in Bhai language

Bhai Language Bhai language is fun Programming language , with this language you can makes jokes in hindi. Bhai language written in typescript. It's very funny , easy and amazing language. Keywords of this language written in Hindi . Starting and ending of the program Start program with keyword " hi bhai " and end with " bye bhai ". It's compulsory to add this keyword before starting and end on the program. You write your programming logic inside this hi bhai and bye bhai . How to declare variables in Bhai language We use " bhai ye hai variable_name" keyword for declaring variables. In javascript we use var keyword for declaring variables but here you have to use " bhai ye hai " keyword. If you are declaring string then use " " double quotes. You can use Boolean variable like sahi and galat for true and false . How to print output in Bhai language You have to use " bol bhai " keyword for