What will be the output of the following C++ code? [code] #include <iostream> #include <cctype> using namespace std; int main(int argc,

What will be the output of the following C++ code?
Code:
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
	char arr[20] = "\'H3ll0\'";
	for(int i=0;i<8;i++)
        {
		cout<<(bool)ispunct(arr[i]);
	}
}
A. 10000010
B. 111111111110
C. 111000111110
D. 111110000000
 
Answer: a
Explanation: In this program we are checking the presence of punctuation characters like quotes(', ", etc.) in the string, so ispunct() returns 1 for single quote positions and returns 0 otherwise.
 

Tìm kiếm

Back
Top