Strings - Find Output of Program :: Discussion


28.What will be the output of the program?
A.Equal
B.Unequal
C.Error
D.None of above
Answer:  Option  B
Explanation:

Step 1char str1[] = "Hello"; The variable str1 is declared as an array of characters and initialized with a string "Hello".

Step 2char str2[] = "Hello"; The variable str2 is declared as an array of characters and initialized with a string "Hello".

We have use strcmp(s1,s2) function to compare strings.

Step 3if(str1 == str2) here the address of str1 and str2 are compared. The address of both variable is not same. Hence the if condition is failed.

Step 4: At the else part it prints "Unequal".

Tutorial Link:
Published by:Michael Daani

Comments are not available

Post your comments here:

Optional

Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers