C++ Programming Concepts and Code Output Quizlet Set

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/34

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

35 Terms

1
New cards

What is printed to the screen when this program runs? (Global int x=10; void print(int y){cout << y << ":" << x;} main(){int x=5; print(x);})

10:10

10:5

5:5

5:10

5:10

2
New cards

Which function prototype would satisfy the line: Z = X + Y; (Where X, Y, Z are BigInt)?

int operator+(int, int, int);

BigInt BigInt::operator+(BigInt, BigInt);

BigInt operator+(BigInt, BigInt);

BigInt BigInt::operator+(int);

BigInt operator+(BigInt, BigInt);

3
New cards

What is printed to the screen when this program is run? (toss throws 42; catch(int); prints "world-", then "awesome-")

hello-world-awesome

world-awesome

the correct answer is not listed

hello-awesome

world-awesome-

4
New cards

Consider the following program. What is printed? (Global x=10; print(y) prints y:x; main defines x=17, calls print(x))

17:10

10:5

10:17

There is a compiler error because there are too many x variables.

17:10

5
New cards

What is printed to the screen when this program is run? (toss throws 42 (int); catch(const char * s);)

Nothing is printed

awesome

hello-awesome

hello-world-awesome

Nothing is printed

6
New cards

What is the BEST programming language EVER? (Code prints ASCII char 67, then +, +)

C++

Python (yeah, right...)

FORTRAN

HammerHead

C++

7
New cards

What is the output of the following program: swap(int &x, int y) { int temp=x; x=y; y=temp; } main() { a=10, b=20; swap(a,b); cout a,b; }

20, 20

10,10

10,20

20,10

20,20

8
New cards

Where does the variable x live? (Global variable defined at top of file)

on the heap

on the stack

on the run

data segment

data segment

9
New cards

Where does the variable y live? (static int y = 20 inside a function)

on the heap

on the stack

on the run

data segment

data segment

10
New cards

Where does the variable ptr live? (int *ptr inside a function)

on the heap

on the stack

on the run

data segment

on the stack

11
New cards

Where does the variable z live? (void scope(int z) - parameter)

on the heap

on the stack

on the run

data segment

on the stack

12
New cards

What will be printed on the screen if I type this command sequence: more numbers.dat | tail -100 | head -25 | tail -1 (File has 1-100 sorted)?

25

none

21

20

25

13
New cards

int A[]={0,1,2,3,4,5}; int *ptr=A; How would I print 5 to the screen?

cout << ptr + 5;

cout << ptr[5];

cout << *ptr[5];

cout << ptr 5;

cout << ptr[5];

14
New cards

What is wrong with the following C++ program: int ptr; int ptr2=&y; y=x; ptr=&x;

nothing is wrong

15
New cards

Where does the variable ptr[5] live? (int *ptr = new int[10]; accessing the array memory)

on the stack

on the heap

on the move

on the spot

on the heap

16
New cards

int a=10; int *ptr = &a; cout << ptr; What is printed out?

the number 10

the contents of a

the memory address of a

the memory address of ptr

the memory address of a

17
New cards

How many numbers will the printArray() function actually print out? (void printArray(int n[]) loop using n.size())

all the numbers in the array

1

10

the correct answer is not listed

the correct answer is not listed (Arrays do not have .size())

18
New cards

Consider the following program. What is the output? (Vector push_back i5 for i 0-9; cout << (it+3))

3

5

it will not compile

15

15

19
New cards

What can be understood from the following Linux command: time sort numbers.dat ... real 0m1.593s?

The command took about 6.9 seconds to run (1.6 + 5.1+0.2)

The correct answer is not listed

The command took about 1.6 seconds to run

The command took about 0.2 seconds to run

The command took about 5.1 seconds to run

The command took about 1.6 seconds to run

20
New cards

How can an object refer to itself in C++?

myself

me

self

this

this

21
New cards

How many characters are there in the standard ASCII table?

256

128

127

255

128

22
New cards

Where does dynamic memory allocation take place?

heap

text segment

stack

data segment

heap

23
New cards

char word [10] = "matrix"; cout << strlen(word); What will be printed?

correct answer is not listed

6

matrix

10

6

24
New cards

In which c++ library is strlen() found?

correct answer not listed

<cstring>

<strlen>

<string>

<cstring>

25
New cards

Which of the answers print the same correct output as A[index]?

cout << A + index:

cout << &A[index];

cout << (A + index);

cout <<*(A + index);

cout << *(A + index);

26
New cards

What is the passing mode used in the function void func(char *ptr)?

pass by value

pass by linkage

pass by reference

pass by touchdown

pass by value

27
New cards

This program will compile and run just fine: cout << "Hello World"; (No using namespace std or std::)

true or false

False

28
New cards

Vector deck; Card c1; What statement will add the card to the deck?
deck.add(c1);

deck = c1:

deck.push_back(c1);

deck.put(c1);

deck.push_back(c1);

29
New cards

Which one of the following operator cannot be overloaded in C++?
operator==

The correct answer is not listed

operator[]

operator&

operator+

The correct answer is not listed (operators like :: or . cannot, but options were ==, [], +, &)

30
New cards

What function is being called: BigInt Y = X++;

BigInt operator++(int);

BigInt BigInt::operator++();

BigInt BigInt::operator++(int);

BigInt operator++();

BigInt operator++(int);

31
New cards

When using friend functions for operator overloading, which of the following statements is true?

Friend functions can only access public members of a class

Friend functions are member functions of a class

Friend functions can access any data member of a class.

Friend functions cannot be used for operator overloading

Friend functions can access any data member of a class.

32
New cards

Which of the following non-member functions is valid syntax for overloading the addition operator (+)?

BigInt operator + (BigInt a, BigInt b)

void operator + (BigInt a, BigInt b)

void operator + (BigInt a)

BigInt operator + (BigInt a)

BigInt operator + (BigInt a, BigInt b)

33
New cards

Which of the following member functions is valid syntax for overloading the operator%() in C++?

void BigInt::operator % (BigInt a, BigInt b)

void BigInt::operator % (BigInt a)

BigInt BigInt::operator % (BigInt a)

BigInt BigInt::operator % (BigInt a, BigInt b)

BigInt BigInt::operator % (BigInt a)

34
New cards

What is the output of the following program: vector v; auto start=v.begin(), end=v.end(); if(start==end) cout "happy" else "sad"?

sad

happy

begin

start

happy

35
New cards

Which value will be removed from the vector? v={1,2,3,4,5,6}; v.erase(v.begin()+3);

3

4

5

6

4