#include <cstring> using namespace std; void catFun(char [], char [], char []);
ID: 3617837 • Letter: #
Question
#include <cstring>
using namespace std;
void catFun(char [], char [], char []); //learned inclass Monday
int cmp(char [], char [], char []); // functionprototype
int main()
{
char first[20], second[20],third[40]; //creating two string of chars
cout<<"Enter First Word:"; //geting firstword
cin>>first;
cout <<" Enter Second Word:"; //getting secondword
cin>>second;
int result=comp(first,second); //passing both words to thefunction
if(result==0)
cout<<" Both are equalwords.";
else
cout<<" DifferentWords.";
return 0;
}
int cmp(char *f, char *s)
{
int len=0;
for(intv=0;f[v]!='0';v++)
if(f[v]!=s[v]) //checking eachand every char of first word with second word, if they aredifferent then incrementing len variable
len++;
if(len>0) //if no char isdifferent then len will not incremented so return1.
return 1;
else //if len is still zero means all the chars arematched.
return 0;
}
Explanation / Answer
please rate - thanks I highlighted the changes. I hope I got them all #include #include using namespace std; void catFun(char [], char [], char []); //learned in classMonday int cmp(char [], char []); // functionprototype int main() { char first[20], second[20], third[40]; //creating two string ofchars coutfirst; cout second; int result=cmp(first,second); //passingboth words to the function if(result==0) coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.