Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C++ 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]);
}
}

What will be the output of the following C++ 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.

Join The Discussion