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[12] = “H3ll0\tW0r1d”;
for(int i=0;i< 12;i++)
{
cout<<(bool)iscntrl(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[12] = “H3ll0\tW0r1d”;
for(int i=0;i< 12;i++)
{
cout<<(bool)iscntrl(arr[i]);
}
}
a) 111111111110
b) 000001000001
c) 111000111110
d) 111110000000

Answer: b
Explanation: In this program we are checking the presence of control codes i.e. \n, \r, \r\n, \t, etc. in the string so accordingly one can find the answer.

Join The Discussion