Comparing Strings

Program for comparing strings in C :

ALGORITHM:

    1. [INITIALISE]flag=0
    2. INPUT string 1, STR1[100]
    3. INPUT string 2, STR2[100]
    4. Calculate length of string 1 and store in len1
    5. Calculate length of string 2 and store in len2
    6. CHECK
      if len1!=len2
      flag=1
      else
      Compare strings character by character and
      SET flag=1 and BREAK if different characters are found.
    7. if flag=0
      PRINT Strings are equal
      else
      PRINT Strings are unequal

C SOURCE CODE:

Leave a Reply

Your email address will not be published. Required fields are marked *