Ask Question
8 May, 01:41

Replace any alphabetic character with '_' in 2-character string passCode. Ex: If passCode is "9a", output is:

9_Hint: Use two if statements to check each of the two characters in the string, using isalpha ().

fix:

#include

#include

#include

using namespace std;

int main () {

string passCode;

cin >> passCode;

/ * Your solution goes here * /

cout << passCode << endl;

return 0;

}

+5
Answers (1)
  1. 8 May, 02:12
    0
    Code which is pasted in the place of " / * Your solution goes here * / ":

    if (isalpha (passCode[0])) / / if statement for the first character of the passcode string.

    passCode[0]='_';

    if (isalpha (passCode[1])) / / if statement for the second character of the passcode string.

    passCode[1]='_';

    Output:

    If the user gives input as '4h', then it will prints '4_'. If the user gives input as 'a8', then the output is '_8'.

    Explanation:

    Missing information:

    There is a three header file missing in the question programming code which names as the "cctype", 'iostream', 'cstring'.

    Code Explanation:

    The above code is in c+ + programing language, which is pasted on the place of " / * Your solution goes here * / ", which is written in the question part. The first if-statement checks the first character of the string that it is a charter or not if it is a character then replace the character with an underscore. The second if-statement is used to check the second character of the staring that is it a character or not if it then replaces the character with an underscore.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Replace any alphabetic character with '_' in 2-character string passCode. Ex: If passCode is "9a", output is: 9_Hint: Use two if statements ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers