What will be the output of the following C++ code
#include
#include
using namespace std;
int main(int argc, char const *argv[])
{
array<int,arr arr1.fill(2);
for(int i=0;i<5;i++)
cout<<arr1[i];
cout<<endl;
return}
20000
20002
22222
00002
Browse topic-based C++ Interview practice sets.
45 practice sets · Page 3 of 3
What will be the output of the following C++ code
#include
#include
using namespace std;
int main(int argc, char const *argv[])
{
array<int,arr arr1.fill(2);
for(int i=0;i<5;i++)
cout<<arr1[i];
cout<<endl;
return}
20000
20002
22222
00002
What is the use of fill() function in array class?
To check whether given element fills the array or not
To replace all the elements of the array which are equal to the given value
To delete all the elements that are equal to the given value
To fill an array with a given single value
What is the use of empty() function in array classes?
To check whether the size of an array is zero or not
To check how many elements are there in the array
To check whether an array contains negative elements or not
To check whether an array is empty or not
What is the syntax of swap()?
arr1.swap(arr2);
swap<int, int>(arr1, arr2);
swap(arr1, arr2);
swap[arr1, arr2];
What is the use of swap() function in array class?
Swaps two arrays
Swaps same elements of the array if required
Swaps two elements given indices of elements
Swaps two elements of an array given elements