Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

C Programming :: String

Home > C Programming > String > General Questions

21. What is the output of the following 'C' program ?

#include
int main()
{
char str1[]="Hello";
char str2[]="Hello";
if ( str1==str2 )
printf("True\n");
else
printf("False\n");
}

Answer: Option B

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 False, i.e, option B. 

Workspace


Tags:  Global Edge

22. What is the output of the following 'C' program ?

#include
int main()
{
char a[] = "world";
printf("%d %d\n",strlen(a),sizeof(a));
return 0;
}

Answer: Option C

Explanation:

strlen() method prints the no. of characters in the character array, here which is 5.

Next, sizeof() operator is used which prints the no. of characters in the character arrar + the '\0' (termination) character, here which is equal to 6.

Hence, the output is 5,6.

Workspace


Tags:  Global Edge

23. What is the output generated?

#include
int main()
{
char *s = "Hello";
printf("%s",(s+1));
return 0;
}

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  Global Edge

24. What is the output of the following 'C' program ?

#include
int main()
{
char *s = "Hello";
printf("%s",1(s));
}

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace


Tags:  Global Edge



Most Popular Qs.

Latest MCQ Qs.