325 views
0 votes
0 votes

Why is the answer a).Answer should be c.Please tell if I am wrong...

1 Answer

0 votes
0 votes

first  you should run this code than you will automatically understand .

#include<stdio.h> 
int main() 

   char s[15]="Sreeja"; 
   char t[15]="Mukherjee"; 
    printf("start address value of S= %d\n",s);
    printf("start address value of t=%d\n",t);
   if(s>t)
       printf("s>t");
    else
        printf("s<t");
}

In the case of String the compiler compare  the address of starting character.(In the case of C)

if you want to read about java than you should check this linkhttps://www.javatpoint.com/string-comparison-in-java

edited by

Related questions

3 votes
3 votes
5 answers
2
arpit.bagri asked Aug 6, 2023
1,088 views
Why is the output of the below program 36? int main(){ int a = 1; int b = ++a * ++a * ++a; printf("%d", b ); ​​​​ return 0; }
0 votes
0 votes
3 answers
4
lalitver10 asked Oct 23, 2021
700 views
#include <stdio.h>int main(){ int a=20; int *ptr=&a; int x=a; printf ("%p\n",&*ptr); printf ("%p\n",&a); return 0;}Why both printf() line printing the s...