Answer to Question #349684 in C++ for Magisk

Question #349684

Instructions:

  1. Check if the value of the char named myself is equal to one of the characters present in the string called others.
  2. Do this by comparing each of the characters in the string to myself.
  3. Print out only the index of the character which matches that of myself. If there are several matches, separate them by a single line.

Given code:

#include <iostream>

using namespace std;


int main() {

  // NOTE: Do not change this

  const char others[100] = "TheQuIckBrownFoxJumpedOvErTheLazyDog";

   

  char myself;


  // TODO: Ask the user for the value of `myself`

 

}

Sample input:

Enter myself: T


26


1
Expert's answer
2022-06-10T18:34:22-0400
#include <iostream>
using namespace std;

int main() {
  // NOTE: Do not change this
  const char others[100] = "TheQuIckBrownFoxJumpedOvErTheLazyDog";
   char myself;
   
   
  // TODO: Ask the user for the value of `myself`
    int i=0;
    cout<<"Enter char: ";
    cin>>myself;
    while(others[i]!='\0'){
        if(others[i]==myself)
            cout<<i<<endl;
        i++;
    }
 }

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
APPROVED BY CLIENTS