Ask Question

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

+2
Answers (1)
  1. 2 October, 18:11
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers