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] = “Hello World”;
for(int i=0;i< 12;i++)
{
cout<<(bool)isalpha(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] = “Hello World”;
for(int i=0;i< 12;i++)
{
cout<<(bool)isalpha(arr[i]);
}
}
a) 111110111110
b) 111111111110
c) 111000111110
d) 111110000000

Answer: a
Explanation: 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.

Join The Discussion