A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • one year ago

C++ question on comparing elements on 2 different arrays

  • This Question is Closed
  1. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Well, what is the question?

  2. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  3. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. rsmith6559
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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/

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.