Given two strings write a program in c to find if set of characters are equal or not.

Dextor
1 min readMar 21, 2022

According to my understanding of the problem, we have to find the lengths of the string and check whether both strings have equal set of character or in other words length of both strings are equal or not.

so if length of both strings are equal return 1 else return 0.

here the use of function like for example: for length of the string : use strlen(str)

constraints: length of strings ≥2

Here goes the programming;

#include <stdio.h>
#include <string.h>

int main() {
char Str1[200], Str2[200];
scanf(“%s”, Str1);
scanf(“%s”, Str2);
if (strlen(Str1) == strlen(Str2)){
printf(“1”);
}else{
printf(“0”);
}
return 0;
}

//char-> string declaration;//Str-> var name; [200]-> size of string array

//strlen(Str)-> best way to get length of strings.

Note: Comment if you feel like this post needs improving.

--

--