Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now