Answer to Question #349685 in C++ for Magisk

Question #349685

Instructions:

  1. Ask the user for a string input
  2. From the string inputted, find the index of the capital letter.
  3. For this problem, it is guaranteed that there is only 1 capital letter in the inputted string.
  4. Hint: Use the isupper(char) function from the cctype library to check if a letter is capital or not.

Example:

Enter string: Philippines



1
Expert's answer
2022-06-10T08:29:55-0400
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
 
int main()    {
string inputString = "";

cout<<"Enter string: ";
getline(cin, inputString);

int i;
  for(i=0; !isupper(inputString[i]);i++ )
  ;

    cout<<i;       

return 0;
}

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