Question: What is the output of the following program? void func1() { cout < < Welcome to ; } void func2() { cout < < COSC

  1. What is the output of the following program?

void func1() { cout << "Welcome to "; }

void func2() { cout << "COSC 1430"; }

int main() {

func1(func2());

return 0;

}

Welcome to COSC 1430

The program will not compile

COSC 1430

Welcome to

  1. Which looping process checks the test condition at the end of the loop, always resulting in at least one iteration?

Do-while

no looping process checks the test condition at the end

For

While

  1. A break statement causes execution to skip to

the statement following the continue statement

the return 0; statement

The next iteration of the loop

the first statement after the loop

  1. The following code compiles:

void print(const int array[], int size) {

for(int i=0; i < size; i++)

cout << array[i]++ << " ";

}

True

False

  1. This function can be used to return the size of an array of integers:

int arraySize(int array[]){

return sizeof(array)/sizeof(array[0]);

}

True

False

  1. What will be the output of the following program?

int main()

{

for(int i=1;i<=2;i++)

{

for(int j=i;j<=2;j++)

cout << i << "A";

}

return 0;

}

112AAA

1A2A1A2A

1A1A2A2A

1A1A2A

  1. Given the structure

struct rectangle {

float height;

float width;

};

what would be the most appropriate signature for a function designed to add two rectangles to create a new one?

struct add(struct r1, struct r2)

float add(rectangle r1, rectangle r2)

float add(float r1, float r2)

rectangle add(rectangle r1, rectangle r2)

  1. What is the output of the following code when x = 1?

switch(x) {

case 1: cout << "First class" << endl;

case 2: cout << "Second class" << endl;

break;

default: cout << "Passenger" << endl;

}

First class

Second class.

First class.

First class

Passenger.

First class

Second class

Passenger.

  1. If you wanted to make sure that the actual variable, not just a copy was sent to a function, how would you pass it?

Pass by value

Pass by parameter

Pass by location

Pass by reference

  1. Which statement opens a file outfile.txt given ofstream outFS;

outFS.open("output.txt");

outFS.open(output.txt);

ofstream.open("output.txt");

ofstream(outFS, output.txt);

  1. When does eof() return true?

When the file can be opened.

When the file cannot be opened.

When the stream reaches the end of the file.

When the stream encountered an error

  1. Complete the code to print every other element of the array, starting from the first one:

int arr[] = {1,2,3,4,5};

for(/*fill the blank*/)

cout << arr[i] << " ";

int i = 0; i<=5; i++

int i = 1; i<5; i+=2

int i = 0; i<5; i+=2

int i = 1; i<=5; i+=2

  1. It is not possible for a function to return a structure variable

True

False

  1. What is the output of the following code?

int sum = 14; if ( sum < 20 ) cout << "Under "; else cout << "Over "; cout << "the limit.";

Over the limit.

Under

Over

Under the limit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!