Computer Science - Object Oriented Programming Using C++ - Discussion
Discussion Forum : Object Oriented Programming Using C++ - Section 11 (Q.No. 12)
12.
The function strcmp("Jose", "JOSE") will return _____
Discussion:
5 comments Page 1 of 1.
Sana said:
9 years ago
Why it will return 1?
Bipin said:
9 years ago
strcmp checks case sensitive chars. So 1.
Rashi Jain said:
8 years ago
That means here 1 is for false.
Lucifer said:
7 years ago
strcmp(str1,str2) returns 0 if two strings are equal.
Returns -1 if str2 is > str1.
Returns 1 if str1 is > str2.
Returns -1 if str2 is > str1.
Returns 1 if str1 is > str2.
Ayesha said:
5 years ago
stricmp() is one of the inbuilt string functions in c programming which is used to compare two strings without any discrimination between uppercase and lowercase letters if the strings are same, it returns 0. Otherwise, it returns a nonzero value.
And the syntax is;
strcmp
strcmp("Jose", "JOSE")
char leftStr[] = "Jose";
char rightStr[] = "JOSE";
Strings are unequal
Value of result: 1
char leftStr[] = "Jose";
char rightStr[] = "Jose";
c
z has greater ASCII value than g
char leftStr[] = "zfz";
char rightStr[] = "gfg";
Strings are unequal
Value of result: >1 like 19
b has less ASCII value than g
char leftStr[] = "bfb";
char rightStr[] = "gfg";
Strings are unequal
Value of result: <1 like (-5)
And the syntax is;
strcmp
strcmp("Jose", "JOSE")
char leftStr[] = "Jose";
char rightStr[] = "JOSE";
Strings are unequal
Value of result: 1
char leftStr[] = "Jose";
char rightStr[] = "Jose";
c
z has greater ASCII value than g
char leftStr[] = "zfz";
char rightStr[] = "gfg";
Strings are unequal
Value of result: >1 like 19
b has less ASCII value than g
char leftStr[] = "bfb";
char rightStr[] = "gfg";
Strings are unequal
Value of result: <1 like (-5)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers