Discussion Forums

New User? Please read instructions!

C program to compare 2 arrays whether they are equal or not  

  RSS

thiyagarajan
Eminent Member
Joined: 6 months  ago
Posts: 26
27/01/2017 9:49 am  

C program to compare 2 arrays whether they are equal or not


ReplyQuote
admin
Eminent Member
Joined: 5 years  ago
Posts: 26
10/02/2017 10:21 am  

C program to compare 2 arrays whether they are equal or not:

 

#include <stdio.h>

#include <string.h>

int main()

{

     char arr1[200], arr2[200];

     printf("Please enter the 1st string\n");

     gets(arr1);

     printf("Please enter the 2nd string\n");

     gets(arr2);

   

     printf("Entered strings are\narr1 = %s \narr2 = %s", arr1, arr2);

 

     if( strcmp(arr1,arr2) == 0 )

          printf("\nEntered strings are equal.\n");

     else

          printf("\nEntered strings are not equal.\n");

     return 0;

}

 

Output:

Please enter the 1st string

This is array1

Please enter the 2nd string

This is array2

Entered strings are

arr1 = This is array1 

arr2 = This is array2

Entered strings are not equal.

Edited: 6 months  ago

ReplyQuote
  
Working

Please Login or Register

1. Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Share this website !!!
Facebook Twitter Linkedin

Close
We Support JALLIKATTU !!!
We Support JALLIKATTU!
By Fresh2Refresh.com
Show Your Support as well. Thanks!