Class 7  >  C++ Programming for Beginners  >  Test: C++ Arrays Download as PDF

Test: C++ Arrays


Test Description

10 Questions MCQ Test C++ Programming for Beginners | Test: C++ Arrays

Test: C++ Arrays for Class 7 2023 is part of C++ Programming for Beginners preparation. The Test: C++ Arrays questions and answers have been prepared according to the Class 7 exam syllabus.The Test: C++ Arrays MCQs are made for Class 7 2023 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: C++ Arrays below.
Solutions of Test: C++ Arrays questions in English are available as part of our C++ Programming for Beginners for Class 7 & Test: C++ Arrays solutions in Hindi for C++ Programming for Beginners course. Download more important topics, notes, lectures and mock test series for Class 7 Exam by signing up for free. Attempt Test: C++ Arrays | 10 questions in 10 minutes | Mock test for Class 7 preparation | Free important questions MCQ to study C++ Programming for Beginners for Class 7 Exam | Download free PDF with solutions
1 Crore+ students have signed up on EduRev. Have you?
Test: C++ Arrays - Question 1

What is the index number of the last element of an array with 9 elements?

Detailed Solution for Test: C++ Arrays - Question 1

Because the first element always starts at 0. So it is on 8 position.

Test: C++ Arrays - Question 2

Which of the following accesses the seventh element stored in array?

Detailed Solution for Test: C++ Arrays - Question 2

The array location starts from zero, So it can accessed by array[6].

Test: C++ Arrays - Question 3

What will be the output of the following C++ code?

    #include <stdio.h>
    #include<iostream>
    using namespace std;
    int array1[] = {1200, 200, 2300, 1230, 1543};
    int array2[] = {12, 14, 16, 18, 20};
    int temp, result = 0;
    int main()
    {
        for (temp = 0; temp < 5; temp++) 
        {
            result += array1[temp];
        }
        for (temp = 0; temp < 4; temp++)
        {
            result += array2[temp];
        }
        cout << result;
        return 0;
    }

Detailed Solution for Test: C++ Arrays - Question 3

In this program we are adding the every element of two arrays. Finally we got output as 6533.
Output:
$ g++ array.cpp
$ a.out
6533

Test: C++ Arrays - Question 4

What will be the output of the following C++ code?

    #include <stdio.h>
    #include<iostream>
    using namespace std;
    int main()
    {
        int a = 5, b = 10, c = 15;
        int arr[3] = {&a, &b, &c};
        cout << *arr[*arr[1] - 8];
        return 0;
    }

Detailed Solution for Test: C++ Arrays - Question 4

The conversion is invalid in this array. So it will arise error. The following compilation error will be raised:
cannot convert from ‘int *’ to ‘int’
This is because &a, &b and &c represent int* whereas the array defined is of int type.

Test: C++ Arrays - Question 5

What will be the output of the following C++ code?

    #include <stdio.h>
    #include <iostream>
    using namespace std;
    int main()
    {
        int array[] = {10, 20, 30};
        cout << -2[array];
        return 0;
    }

Detailed Solution for Test: C++ Arrays - Question 5

It’s just printing the negative value of the concern element.
$ g++ array.cpp
$ a.out
-30
 

Test: C++ Arrays - Question 6

Which of the following correctly declares an array?

Detailed Solution for Test: C++ Arrays - Question 6

Because array variable and values need to be declared after the datatype only.

Test: C++ Arrays - Question 7

What is the correct definition of an array?

Detailed Solution for Test: C++ Arrays - Question 7

Correct definition of an array is An array is a series of elements of the same type in contiguous memory locations.

Test: C++ Arrays - Question 8

Which of the following gives the memory address of the first element in array?

Detailed Solution for Test: C++ Arrays - Question 8

To get the address of ith index of an array, we use following syntax (arr + i). So as we need address of first index we will use (arr + 0) equivalent to arr.

Test: C++ Arrays - Question 9

What will be the output of the following C++ code?

    #include <stdio.h>
    #include<iostream>
    using namespace std;
    int main ()
    {
        int array[] = {0, 2, 4, 6, 7, 5, 3};
        int n, result = 0;
        for (n = 0; n < 8; n++) 
        {
            result += array[n];
        }
        cout << result;
        return 0;
    }

Detailed Solution for Test: C++ Arrays - Question 9

We are adding all the elements in the array and printing it. Total elements in the array is 7, but our for loop will go beyond 7 and add a garbage value.

Test: C++ Arrays - Question 10

What will be the output of the following C++ code?

    #include <stdio.h>
    #include <iostream>
    using namespace std;
    int main()
    {
        char str[5] = "ABC";
        cout << str[3];
        cout << str;
        return 0;
    }

Detailed Solution for Test: C++ Arrays - Question 10

We are just printing the values of first 3 values.
$ g++ array.cpp
$ a.out
ABC

15 videos|20 docs|13 tests
Use Code STAYHOME200 and get INR 200 additional OFF
Use Coupon Code
Information about Test: C++ Arrays Page
In this test you can find the Exam questions for Test: C++ Arrays solved & explained in the simplest way possible. Besides giving Questions and answers for Test: C++ Arrays, EduRev gives you an ample number of Online tests for practice