C Programming :: String - Discussion
Home > C Programming > String > MCQs Questions Discussion
11 / 26
What is the output of the following 'C' program ?
#include<stdio.h>
void main()
{
char str1[] = "Hello";
char str2[] = "Hello";
if (str1 == str2)
printf("\nequal");
else
printf("\nUnequal");
}
#include<stdio.h>
void main()
{
char str1[] = "Hello";
char str2[] = "Hello";
if (str1 == str2)
printf("\nequal");
else
printf("\nUnequal");
}
AEqual
BError
CUnequal
DNone of these
Answer: Option (Login/Signup)
Show Explanation
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 Unequal, i.e, option C.
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 Unequal, i.e, option C.
Read Full Answer
Report Error
Please Login First Click Here