Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Radhu1 Q-1 How many times will variable i be printed to the screen? for (i = 1;

ID: 673388 • Letter: R

Question

Radhu1

Q-1 How many times will variable i be printed to the screen?
for (i = 1; i <= 20; i = i + 2);
{
cout << “ “ << i ;
}

A. 10

B. 20

C. 1

D. 0

Q-2 What is the final number output for the following code snippet?
for (i = 1 ; i <= 20 ; i = i + 2);
cout << “ “ << i ;

A. 10

B. 19

C. 20

D. This is an illegal set-up of for loop parameters.

Q-3 What is the declaration for a C-style string that can hold a name with up to 3 printable characters (for example, “Ron”)?

A. int name [3];

B. char name [3];

C. int name [4];

D. char name [4];

Q-4 The following code fragment
struct student
{
string name;
double gpa;
};
student thisStudent;
cout << “Enter this student’s name: “ << flush;
cin >> thisStudent.name;
cout << “Enter this student’s GPA: “ << flush;
cin >> thisStudent.gpa;
student nextStudent = thisStudent;

A. copies both thisStudent’s name and gpa to nextStudent.

B. displays the name and gpa of thisStudent.

C. causes a compiler error.

D. causes a run-time error.

Q-5 Given the following code fragment, what is the data type of roster[9] .name?
struct student
{
string name;
double gpa;
};
student thisStudent;
student roster[50];

A. string

B. const pointer to student

C. student

D. double

Explanation / Answer

Q-1 : C
Q-2 : Not in the Choice(Ans : 21)
Q-3 : B
Q-4 : D
Q-5 : A