Once you attempt the question then PrepInsta explanation will be displayed.
Initialize a string s with the value "prepinsta".
Initialize an integer variable i with a value of 0.
Start a for loop with j initialized to the length of the string s minus 1 (which is 8 in this case) and decrementing j by 1 until j becomes less than 4.
Inside the loop, print the character at index i in the string s.
Increment i by 2.
Now, let's go through the loop iterations:
j = 8, i = 0. Print s[0] = 'p'. i is incremented to 2.
j = 7, i = 2. Print s[2] = 'e'. i is incremented to 4.
j = 6, i = 4. Print s[4] = 'i'. i is incremented to 6.
j = 5, i = 6. Print s[6] = 's'. i is incremented to 8.
j = 4, i = 8. Print s[8] = 'a' i is incremented to 10
The loop ends when j becomes 4, so the last character printed is the null terminator '\0' which is an invisible character used to mark the end of a string in C++. It won't be displayed in the output.
So, the output of the given pseudocode will be: "peisa"
Login/Signup to comment