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<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

2 Answers  


main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }

2 Answers  


Predict the Output: int main() { int *p=(int *)2000; scanf("%d",2000); printf("%d",*p); return 0; } if input is 20 ,what will be print

2 Answers  


what is oop?

3 Answers  


main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 Answers  






How to palindrom string in c language?

6 Answers   Google,


1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?

2 Answers  


How can i find first 5 natural Numbers without using any loop in c language????????

2 Answers   Microsoft,


main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }

2 Answers  


There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }

1 Answers  


How we print the table of 2 using for loop in c programing?

14 Answers   HCL, Wipro,


What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }

1 Answers  


Categories