C Programming :: String - Discussion
Home > C Programming > String > MCQs Questions Discussion
21 / 26
What is the output of the following 'C' program ?
#include<stdio.h>
int main()
{
char str1[]="Hello";
char str2[]="Hello";
if ( str1==str2 )
printf("True\n");
else
printf("False\n");
}
#include<stdio.h>
int main()
{
char str1[]="Hello";
char str2[]="Hello";
if ( str1==str2 )
printf("True\n");
else
printf("False\n");
}
ATRUE
BFALSE
CError
DUnpredictable
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
The '==' operator is meant for reference comparison i.e, it returns true only if the 2 string objects are same, else it will return false. Here, since the 2 string objects are different, the else part gets executed, and the output is False, i.e, option B.
Read Full Answer
Report Error
Please Login First Click Here