ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
What happens when both of the following C++ programs are compiled and executed
===== Program 1 =====
#include <iostream>
#include <array>
using namespace std;
int main()
{
array<int,arr arr1.fill(5);
cout<<get<5>(arr1);
return}
=====================
===== Program 2 =====
#include <iostream>
#include <array>
using namespace std;
int main()
{
array<int,arr arr1.fill(5);
cout<<arr1.at(5);
return}
=====================
Correct Answer: D — Program 1 gives compile-time error and Program 2 gives run-time error
fill() function sets the value of each element equal to the value passed as parameter to the function.