C Program To Take A String As An Input From The User Using %c And %s. Confirm That The Strings Are Equal.


Program Code:

#include <stdio.h>
#include <string.h>  
int main()
{
    char string1[100], string2[100];
    scanf("%[^\n]\ns", string1);
    printf("Enter the first string: %s", string1);
    scanf("%[^\n]\ns", string2);
    printf("\nEnter the second string: %s", string2);
    printf("\nAre both strings same: ");
    if (strcmp(string1, string2) == 0) 
{
    printf("Yes");
}
    else 
{
    printf("No");
}
    return 0;
}


To learn more about programming and coding visit our website. PDF study materials also available on our website.

Log on to: www.thecode11.com