Class 10 Exam  >  Class 10 Tests  >  C++ Programming for Beginners  >  Test: C++ Structures - Class 10 MCQ

Test: C++ Structures - Class 10 MCQ


Test Description

10 Questions MCQ Test C++ Programming for Beginners - Test: C++ Structures

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

What will be used when terminating a structure?

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

While terminating a structure, a semicolon is used to end this up.

Test: C++ Structures - Question 2

The declaration of the structure is also called as?

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

The structure declaration with open and close braces and with a semicolon is also called structure specifier.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: C++ Structures - Question 3

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

    #include <iostream>
    using namespace std;
    struct Time 
    {
        int hours;
        int minutes;
        int seconds;
    };
    int toSeconds(Time now);
    int main()
    {
        Time t;
        t.hours = 5;
        t.minutes = 30;
        t.seconds = 45;
        cout << "Total seconds: " << toSeconds(t) << endl;
        return 0;
    }
    int toSeconds(Time now)
    {
        return 3600 * now.hours + 60 * now.minutes + now.seconds;
    }

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

In this program, we are just converting the given hours and minutes into seconds.
Output:
$ g++ stu1.cpp
$ a.out
Total seconds:19845

Test: C++ Structures - Question 4

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

    #include <iostream>
    using namespace std;
    struct sec 
    {
        int a;
        char b;
    };
    int main()
    {
        struct sec s ={25,50};
        struct sec *ps =(struct sec *)&s;
        cout << ps->a << ps->b;
        return 0;
    }

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

In this program, We are dividing the values of a and b, printing it.
Output:
$ g++ stu5.cpp
$ a.out
252

Test: C++ Structures - Question 5

Which of the following accesses a variable in structure *b?

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

Because arrow operator(->) is used to access members of structure pointer whereas dot operator(.) is used to access normal structure variables.

Test: C++ Structures - Question 6

The data elements in the structure are also known as what?

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

Variables declared inside a class are called as data elements or data members.

Test: C++ Structures - Question 7

What will happen when the structure is declared?

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

While the structure is declared, it will not be initialized, So it will not allocate any memory.

Test: C++ Structures - Question 8

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

    #include <iostream>
    #include <string.h>
    using namespace std;
    int main()
    {
        struct student 
        {
            int num;
            char name[25];
        };
        student stu;
        stu.num = 123;
        strcpy(stu.name, "John");
        cout << stu.num << endl;
        cout << stu.name << endl;
        return 0;
    }

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

We are copying the value john to the name and then we are printing the values that are in the program.
Output:
$ g++ stu.cpp
$ a.out
123
john

Test: C++ Structures - Question 9

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

    #include <iostream>
    using namespace std;
    int main()
    {
        struct ShoeType 
        {
           string style;
           double price;
        };
         ShoeType shoe1, shoe2;
         shoe1.style = "Adidas";
         shoe1.price = 9.99;
         cout << shoe1.style << " $ "<< shoe1.price;
         shoe2 = shoe1;
         shoe2.price = shoe2.price / 9;
         cout << shoe2.style << " $ "<< shoe2.price;
         return 0;
    }

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

We copied the value of shoe1 into shoe2 and divide the shoe2 value by 9, So this is the output.
Output:
$ g++ stu2.cpp
$ a.out
Adidas $ 9.99
Adidas $ 1.11

Test: C++ Structures - Question 10

Which of the following is a properly defined structure?

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

option struct {int a;} is not correct because name of structure and ;(after declaration) are missing. In option struct a_struct {int a;} ; is missing. In option struct a_struct int a; {} are missing.

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

Top Courses for Class 10

15 videos|20 docs|13 tests
Download as PDF

Top Courses for Class 10