Question
1)Which of the following struct definitions is correct in C++? a. struct studentType { int ID = 1; }; b. struct studentType { int ID;
1)Which of the following struct definitions is correct in C++?
a. | struct studentType { int ID = 1; }; | |
b. | struct studentType { int ID; }; | |
c. | int struct studentType { ID; } | |
d. | struct studentType { string name; int ID; double gpa; } |
2. A struct variable can be passed as a parameter ____.
a. | only by const | |
b. | only by reference | |
c. | only by value | |
d. | either by value or by reference |
3) You can use an assignment statement to copy the contents of one struct into another struct of the same type.
True
False
4) Consider the following statements. struct circleData { double radius; double area; double circumference; };
circleData circle; Which of the following statements is valid in C++?
a. | cin >> circle.radius; | |
b. | cin >> circle; | |
c. | cin >> circle.radius; circle.area = 3.14 * radius * radius; | |
d. | cin >> circle.radius; circle.area = 3.14 * circle.radius * radius; |
5.
Typically, in a program, a struct is defined ____ in the program.
a. | in the main function | |
b. | before the definitions of all the functions | |
c. | after the definitions of all the functions | |
d. | in any function |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started