What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Microsoft");
for (size_t i = 0; i < str.length();)
{
cout << str.at(i-1);
}
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Microsoft");
for (size_t i = 0; i < str.length();)
{
cout << str.at(i-1);
}
return 0;
}A. M
B. Microsoft
C. Micro
D. runtime error
Answer: Option D

Join The Discussion