C Program to compare arrays

Problem Statement

You need to write a program in C to compare two arrays of characters and display if they are equal or not.

How to compare two arrays in C ?

#include <stdio.h> 
#include <string.h> 
int main() 
     char arr1[35], arr2[35]; 
     printf("Please enter the 1st string\n"); 
     printf("Please enter the 2nd string\n"); 
     printf("Entered strings are\narr1 = %s \narr2 = %s", arr1, arr2); 
     if( strcmp(arr1,arr2) == 0 ) 
          printf("\nEntered strings are equal.\n"); 
          printf("\nEntered strings are not equal.\n"); 
     return 0; 

Leave Your Comment

Liked this content?. Please spread the word :)