Ask Question
29 October, 12:17

What is the output of the code snippet given below? string s = "abcde"; int i = 1; while (i < 5) { cout << s. substr (i, 1); i++; }a. no outputb. abcdc. abcde d. bcde

+3
Answers (1)
  1. 29 October, 14:35
    0
    The answer is "Option d".

    Explanation:

    In the given C+ + program code, two-variable is defined, that is "s and i", in which variable s is a string type that holds a value, that is "abcde", and variable i is an integer type, that holds a value '1'.

    In the next line, a while loop is declared, that uses integer variable which value is less than 5, inside a loop a substring function is used, that specifies the number of character and return its value. In array and string indexing starts from 0, and that variable i starts from 1, that is used in substring function, that's why it will print only "bcde".
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What is the output of the code snippet given below? string s = "abcde"; int i = 1; while (i < 5) { cout ...” 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