1)Which of the following struct definitions is correct in C++? a. struct student
ID: 3801173 • Letter: 1
Question
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
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;
}
Explanation / Answer
1) b
2) d. either by value or by reference.
3) true
4) a
5) b. before the definitions of all the functions.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.