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 W0r1d”;
for(int i=0;i< 12;i++)
{
cout<<(bool)isalpha(arr[i]);
}
cout<< endl;
for(int i=0;i< 12;i++)
{
cout<<(bool)isdigit(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 W0r1d”;
for(int i=0;i< 12;i++)
{
cout<<(bool)isalpha(arr[i]);
}
cout<< endl;
for(int i=0;i< 12;i++)
{
cout<<(bool)isdigit(arr[i]);
}
}
a) 000000000000
010010010100
b) 101100100010
010010010111
c) 111111101010
010010000000
d) 101100101010
010010010100

Answer: d
Explanation: In this program, we are first checking the alphabets in the string then digits in the string so accordingly one can find the answer.

Join The Discussion