Vidyalelo
C++ Programming · Q828

C++ miscellaneous

Programming · C++ Programming · question 828

Q828

What will be the output of the following C++ code? #include #include using namespace std; int main(int argc, char const *argv[]) array arr = 1,2,3,4,5; cout<<"Printing Using [] operator: "; for(int i=0;i<5;i++) cout<<arr[i]<<" "; cout<<endl; cout<<"Printing Using at() function: "; for(int i=0;i<5;i++) cout<<arr.at(i)<<" "; cout<<endl; return 0;

A.
1 2 3 4 5
1 2 3 4 5
B.
Printing Using [] operator: 1 2 3 4 5
Printing Using at() function: 1 2 3 4 5
Answer
C.
Printing Using at() function: 1 2 3 4 5
Printing Using [] operator: 1 2 3 4 5
D.
Printing Using at() function: 1 2 3 4 5

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board