Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Chapter: 17
Q241:
What is the purpose of the C language function isdigit?
A. To check if a character is an alphabet
B. To check if a character is a digit
C. To convert a character to uppercase
D. To convert a character to lowercase
Correct Answer: B
Chapter: 17
Q242:
Which header file is required to use string manipulation functions in C?
A. stdio.h
B. ctype.h
C. string.h
D. stdlib.h
Correct Answer: C
Chapter: 17
Q243:
What does the strlen function do?
A. Copies a string from one location to another
B. Concatenates two strings
C. Determines the length of a string
D. Compares two strings
Correct Answer: C
Chapter: 17
Q244:
How does the strcpy function work?
A. Copies at most n characters of one string to another
B. Concatenates two strings
C. Copies a string from one location to another
D. Compares two strings
Correct Answer: C
Chapter: 17
Q245:
Which function would you use to check if a character is a lowercase letter?
A. isalpha
B. isspace
C. islower
D. isupper
Correct Answer: C
Chapter: 17
Q246:
What is the output of the atoi function when provided with the string "45.5"?
A. 45.5
B. 45
D. Error
Correct Answer: B
Chapter: 17
Q247:
Which function locates the first occurrence of a character in a string?
A. strrchr
B. strstr
C. strchr
D. strpbrk
Correct Answer: C
Chapter: 17
Q248:
What does the strcat function do?
A. Compares two strings
B. Copies part of a string
C. Appends one string to another
D. Converts a string to an integer
Correct Answer: C
Chapter: 17
Q249:
How does strncat differ from strcat?
A. strncat appends up to n characters
B. strncat replaces characters
C. strncat does not append characters
D. strncat copies strings
Correct Answer: A
Chapter: 17
Q250:
Which function would you use to convert a string to a long integer?
A. atof
B. atoi
C. atol
D. strtol
Correct Answer: C
Chapter: 17
Q251:
What does the toupper function do?
A. Converts a character to lowercase
B. Converts a character to uppercase
C. Checks if a character is uppercase
D. Checks if a character is lowercase
Correct Answer: B
Chapter: 17
Q252:
What does the strspn function return?
A. The length of the initial segment of s1 consisting only of characters in s2
B. The length of s1
C. The position of the first occurrence of a character in s1
D. The length of s1 not containing characters in s2
Correct Answer: A
Chapter: 17
Q253:
What type of data does the isspace function check?
A. Only alphabets
B. Only digits
C. Whitespace characters
D. Control characters
Correct Answer: C
Chapter: 17
Q254:
Which of the following functions is used to break a string into tokens?
A. strtok
B. strchr
C. strpbrk
D. strspn
Correct Answer: A
Chapter: 18
Q255:
What are the primary types of files in a computer?
A. Text files and Image files
B. Text files and Program files
C. Program files and Image files
D. Text files and Data files
Correct Answer: B
Chapter: 18
Q256:
What type of files contain formatted text, such as bold or italic characters?
A. Plain text files
B. Executable files
C. Word processor files
D. Program files
Correct Answer: C
Chapter: 18
Q257:
Which header file is required for file handling in C++?
A. <iostream.h>
B. <fstream.h>
C. <stdio.h>
D. <conio.h>
Correct Answer: B
Chapter: 18
Q258:
Which of the following streams is used to read from a file in C++?
A. ofstream
B. cout
C. ifstream
D. cin
Correct Answer: C
Chapter: 18
Q259:
What function is used to open a file in C++?
A. openfile()
B. fileopen()
C. open()
D. fopen()
Correct Answer: C
Chapter: 18
Q260:
Which of the following modes is used to open a file for input in C++?
A. ios::out
B. ios::in
C. ios::app
D. ios::trunc
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now