main()
{
char str1[] = {‘s’,’o’,’m’,’e’};
char str2[] = {‘s’,’o’,’m’,’e’,’\0’};
while (strcmp(str1,str2))
printf(“Strings are not equal\n”);
}
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 |
What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }
main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }
Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines
#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }
write a c-program to find gcd using recursive functions
Is the following code legal? struct a { int x; struct a b; }
#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d..%d",*p,*q); }
PROG. TO PRODUCE 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
Write a program to receive an integer and find it's octal equivalent. How can i do with using while loop.
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*/ }
abcdedcba abc cba ab ba a a
Write a single line c expression to delete a,b,c from aabbcc