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

  • برمجة سي c

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.

هل كان المحتوى مفيد؟

القوائم الدراسية التي ينتمي لها السؤال

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...