Homework help with Structures Please correct and explain mistakes that I made in
ID: 3558972 • Letter: H
Question
Homework help with Structures
Please correct and explain mistakes that I made in the following questions:
1. Which of the following is an example of a C++ primitive data type?Answer:D.
a.unsigned short int
b.long double
c.unsigned char
d.All of these
e.None of these
2. This is required after the closing brace of the structure declaration. Answer:C.
a.square bracket
b.period
c.semicolon
d.colon
e.None of these
3.. If Circle is a structure tag, the statement Answer:B.
Circle doSomething(Circle c2)
can be the header line for a function that:
a.determines and returns the area of a circle
b.takes a Circle structure as a parameter, does something, and returns a Circle structure
c.operates on a constant reference to a Circle structure
d.takes two Circle parameters and does something
e.None of these
4.. Data types that are created by the programmer are known as: Answer:B.
a.variables
b.abstract data types (ADT)
c.functions
d.parameters
e.None of these
5.. This allows you to access structure members. Answer:B.
a.structure access operator
b.dot operator
c.#include <structaccess> directive
d.getmember function
e.None of these
6.. A function ___________ return a structure. Answer:B.
a.may
b.may not
c.will always
d.cannot possibly
e.None of these
7.. A structure _____________ contain members of the same data type. Answer:B
a.cannot
b.can
c.shouldn't
d.None of these
8.. Which of the following statements outputs the value of the gpa member of element 1 of the student array? Answer:C.
a.cout << student1.gpa;
b.cout << firstStudent.gpa;
c.cout << student[1].gpa;
d.cout << student1*gpa;
e.None of these
9.. Look at the following structure declaration. Answer:D.
struct Employee
{
char name[25];
int idNum;
};
In this declaration, Employee is:
a.a member
c.a user-defined data type
b.an array
d.None of these
10. Look at the following structure declaration. Answer:A.
struct Employee
{
char name[25];
int idNum;
};
In this declaration, idNum is
a.
a member
c.
a tag
b.
an array
d.
None of these
Explanation / Answer
1. d.All of these
2. c.semicolon (A strcuture should have a semicolon at its end)
3. b.takes a Circle structure as a parameter, does something, and returns a Circle structure(The function is taking one parameter of type Circle and returning Circle object)
4.b.abstract data types (ADT)
5.b.dot operator (dot operator is used to access members of a structure)
6.b.may not ( a function can return any value and it may not b a structure)
7.b.can ( a structure can contain any umber of parameters of any type)
8.c.cout << student[1].gpa;
9.c.a user-defined data type (Because structures are user defined datatypes used to store any user deined data)
10.a member
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.