Test Series - cpp

Test Number 19/102

Q: Which function is used to check whether a character is an alphabet?
A. isalpha()
B. isalnum()
C. isdigit()
D. isblank()
Solution: Character classification provides isalpha() function to check whether a character in C++ is an alphabet or not.
Q: Which function is used to check whether a character is an alphabet or number?
A. isalpha()
B. isalnum()
C. isdigit()
D. isblank()
Solution: Character classification provides isalnum() function to check whether a character in C++ is alphabet or number.
Q: Which function is used to check whether a character is a number?
A. isalpha()
B. isalnum()
C. isdigit()
D. isblank()
Solution: Character classification provides isdigit() function to check whether a character in C++ is number or not.
Q: Which function is used to check whether a character is a tab or space?
A. isalpha()
B. isalnum()
C. isdigit()
D. isblank()
Solution: Character classification provides isblank() function to check whether a character in C++ is space or tab.
Q: Which function is used to check whether a character is tab or space or whitespace control code(
,
,etc.)?
A. isspace()
B. isalnum()
C. iscntrl()
D. isblank()
Solution: Character classification provides isspace() function to check whether a character in C++ is tab or space or whitespace control code(
, 
, etc.).
Q: Which function is used to check whether a character is tab or a control code?
A. isspace()
B. isalnum()
C. iscntrl()
D. isblank()
Solution: Character classification provides iscntrl() function to check whether a character in C++ is tab or a control code.
Q: Which function is used to check whether a character is printable on console?
A. isxdigit()
B. isprint()
C. iscntrl()
D. ispunct()
Solution: Character classification provides isprint() function to check whether a character in C++ is printable on console.
Q: Which function is used to check whether a character is hexadecimal?
A. isxdigit()
B. isprint()
C. iscntrl()
D. ispunct()
Solution: Character classification provides isxdigit() function to check whether a character in C++ is hexadecimal.
Q: Which function is used to check whether a character is punctuation mark?
A. isxdigit()
B. isprint()
C. iscntrl()
D. ispunct()
Solution: Character classification provides ispunct() function to check whether a character in C++ is punctuation mark.
Q: What will be the output of the following C++ code?

#include 
#include 
using namespace std;
int main(int argc, char const *argv[])
{
	char arr[12] = "Hello World";
	for(int i=0;i<12;i++)
        {
		cout<<(bool)isalpha(arr[i]);
	}
}
A. 111110111110
B. 111111111110
C. 111000111110
D. 111110000000
Solution: In this program we are checking whether a character is an alphabet or not so in “Hello World” except space everything is alphabet, therefore, we have 11111011111 but it is followed by a 0 because every string is followed by a null character which is not alphabet, therefore, we have 0 at the of the binary string.

You Have Score    /10