main()

{

char str1[] = {‘s’,’o’,’m’,’e’};

char str2[] = {‘s’,’o’,’m’,’e’,’\0’};

while (strcmp(str1,str2))

printf(“Strings are not equal\n”);

}



main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {..

Answer / susie

Answer :

“Strings are not equal”

“Strings are not equal”

….

Explanation:

If a string constant is initialized explicitly with
characters, ‘\0’ is not appended automatically to the
string. Since str1 doesn’t have null termination, it treats
whatever the values that are in the following positions as
part of the string until it randomly reaches a ‘\0’. So str1
and str2 are not the same, hence the result.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Code Interview Questions

#include"math.h" void main() { printf("Hi everybody"); } if <stdio.h> will be included then this program will must compile, but as we know that when we include a header file in "" then any system defined function find its defination from all the directrives. So is this code of segment will compile? If no then why?

2 Answers  


#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }

1 Answers  


main() { char *p; p="Hello"; printf("%c\n",*&*p); }

1 Answers  


struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }

1 Answers  


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,






#include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }

1 Answers  


posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come

2 Answers   GATE,


Extend the sutherland-hodgman clipping algorithm to clip three-dimensional planes against a regular paralleiepiped

1 Answers   IBM,


Write a program to receive an integer and find its octal equivalent?

7 Answers  


What are segment and offset addresses?

2 Answers   Infosys,


How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?

0 Answers  


write a c program to print magic square of order n when n>3 and n is odd?

1 Answers   HCL,


Categories