C program to Compare Strings (Manual)

#include <stdio.h>
int main() 
{
    char s1[50], s2[50];
    int i, flag = 0;

    printf("Enter the two strings : ");
    scanf("%s %s", s1, s2);

    for(i = 0; s1[i] != '\0' || s2[i] != '\0'; i++)
 {
        if(s1[i] != s2[i])
 {
            flag = 1;
            break;
        }
    }

    if(flag == 0)
        printf("Equal");
    else
        printf("Not Equal");
}

Comments

Popular posts from this blog

Single Program Using All Automatic String Functions

C program for subtraction of two matrices (2D Arrays)

C program for Multiplication of Two matrices