Answers for "oop244.ca"

C
0

oop244

// Compare Two Strings
 // compare_string.c

 #include <stdio.h>
 #include <string.h>

 int main(void)
 {
         char str1[31], str2[31];
         int i, len;

         printf("Enter first string  : ");
         scanf("%30[^n]%*c", str1);
         printf("Enter second string : ");
         scanf("%30[^n]%*c", str2);
         if (strcmp(str1, str2) < 0)
                 printf("%s precedes %sn", 
                  str1, str2); 
         else if(strcmp(str1, str2) > 0)
                 printf("%s follows %sn",
                  str1, str2);
         else
                 printf("%s matches %sn",
                  str1, str2);

         return 0;
 }
Posted by: Guest on March-04-2020

Code answers related to "C"

Browse Popular Code Answers by Language