Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

C++ question on comparing elements on 2 different arrays

OpenStudy (e.mccormick):

Well, what is the question?

OpenStudy (anonymous):

oh that is strange the rest of the question not there. sorry question is how to compare elements of 2 string arrays. one array is holding all the correct answers to a test. second array is holding all the answers from the students. The student receives points if the elements are the same from the two arrays

OpenStudy (anonymous):

well if your question is how to compare elements of two different arrays then all you need to do is: for(int i=0;i<n;i++) { if(arr1[i]==arr2[i]) cout<<i<<"th element matches in both the arrays"; else cout<<i<<"th element in array 1 is "<<arr1[i]<<" and in array 2 is "<<arr2[i]; } here arr1[] is array 1, arr2[] is array 2 and i is a counter variable.

OpenStudy (rsmith6559):

Because this is string data, the answers need to have their case set too. Either compare them as all uppercase or all lowercase or you'd have to get into Regular Expressions. This URL should help with the comparisons: http://www.cplusplus.com/reference/cstring/

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!