Answer to Question #280012 in C++ for Priyanshu Saurabh

Question #280012

Define two function in a class name matching. In the first function pass a single char array and match the repeated characters. The second function have two char array parameter and match that both are same strings or not.

1
Expert's answer
2021-12-16T04:46:37-0500
#include<iostream>
#include<string.h>
using  namespace std;
class name{
	public:
		void firstFunction(char arr[], char arr2[], int n, int x){
			int size =n;
			if(x>n){
				size = x;
			}
			int i;
			for(i=0; i<size; i++){
				if(arr[i]==arr2[i]){
					cout<<"Matching\n";
				}
				else{
					cout<<"Not matching\n";
				}
			}
		}
		
			void secondFunction(char arr[], char arr2[], int n, int x){
			int size =n;
			if(x>n){
				size = x;
			}
			int i;
			bool found = true;
			for(i=0; i<size; i++){
				if(arr[i] !=arr2[i]){
					found = false;
				}
			
			}
			if(found==true){
				cout<<"The strings are matching\n";
			}
			else{
				cout<<"The string are not matching\n";
			}
			
		}
};
int  main(){
name n;
n.secondFunction("java", "java",4,4);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog