Loading practice questions
What happens when both of the following C++ programs are compiled and executed
===== Program 1 =====
#include
#include
using namespace std;
int main()
{
array<int,arr arr1.fill(5);
cout<<get<5>(arr1);
return}
=====================
===== Program 2 =====
#include
#include
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
Explanation:
fill() function sets the value of each element equal to the value passed as parameter to the function.