COMPSCI-9 Q3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

#include <iostream>

Which header file lets us work with input and output objects? #include <iostream> #include <iostrings #include <stream> #include <inputstr>

class

Which keyword is used to create a class in C++? class() class MyClass className

return

Which keyword is used to return a value inside a method? return break get void

max(x,y)

Which method can be used to find the highest value of x and y? maxNum(x,y) largest(x,y) max(x,y) maximum(x,y)

length()

Which method can be used to find the length of a string? getSize() length() getLength() len()

==

Which operator can be used to compare two values? == = >< <>

The + sign

Which operator is used to add together two values? The + sign The & sign The * sign

*

Which operator is used to multiply numbers? * % X #

break

Which statement is used to stop a loop? break stop return exit

False

a WHILE...ENDWHILE loop ends once the loop condition becomes ____.

WHILE loop

A loop that continues to repeat while a condition is true. It loops until the condition provided returns false, then stops

0

Array indexes start with what number?

functionName();

How do you call a function in C++? functionName; functionName[]; (functionName); functionName();

functionName()

How do you create a function in C++? functionName() functionName[] (functionName) functionName

With the & operator

How do you create a reference variable of an existing variable? With the ref word With the operator With the REF word With the & operator

double x = 2.87;

How do you create a variable with the floating number 2.87? double x = 2.87; byte x = 2.8; int x = 2.8; x=28;

int x = 5;

How do you create a variable with the numeric value 5? int x = 5; x = 5; double x = 5; num x = 5

// This is a comment

How do you insert COMMENTS in C++ code? // This is a comment /* This is a comment # This is a comment

while (x > y)

How do you start writing a while loop in C++? while (x > y) while x > y { while x > y: x > y while {

if (x > y)

How do you start writing an if statement in C++? if (x > y) if x > y; if x>y then:

[]

To declare an array in C++, define the variable type with: [] () {}

True Explanation: The break statement exits a for or while loop completely. To skip the rest of the instructions in the loop and begin the next iteration, use a continue statement. - Break is not defined outside a for or while loop. - The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.

True or False: Using the break or continue statements cause with a loop violates the single entry exit guidelines for developing a loop

False Explanation: The innermost loop is executed first before the outermost loop

True or False: With nested loops, the outermost loop is often totally completed before the innermost loop is executed

False Explanation: if the conditional expression evaluates to true, the body of the loop IS performed until the conditional expression becomes false

True or False: with WHILE loops, if the conditional expression evaluates to true, the body of the loop is not performed; control transfers to the statements following the loop.

False

True or False? C++ is an alias of C#

True

True or False? In C++, it's possible to inherit attributes and methods from one class to another

False Explanation: The value of a string variable should be surrounded by double quotes.

True or False? The value of a string variable can be surrounded by single quotes.

cout << "Hello World";

What is a correct syntax to output "Hello World" in C++? cout << "Hello World"; Console.WriteLine("Hello World"); System.out.println("Hello World"); print ("Hello World");

MyClass myObj;

What is the correct way to create an object called myObj of MyClass? class myObj = new MyClass(); MyClass myObj; class MyClass = new myObj(); new myObj = MyClass();

You are rich!

What is the result? Number of coins = 10. If number_of_coins == 6; cout << You can buy some gum"; else if number_of_coins == 10 cout<< You are rich!"; cout <<"Get a job";

Nested

When one control statement is located within another, it is said to be ____.

string

Which data type is used to create a variable that should store text? string myString Txt String

selection structure

it consists of IF ELSE statements and switch case statements

Loops

other name for iterative statements

decision maker

the expression in an IF statement is sometimes called an _____

(1) for (2) while

two types of loops (2)

nested loop

what do you call a loop within a loop

Iterative Statements

what is a statement that repeats something?

FOR loop

when a loop has happened a set number of times, it is a ____.

b. if (x = 5) Explanation: if (x = 5) does not compare x to 5, it instead initializes x as 5. The format is also wrong.

which of the following will cause an error if you are attempting to compare x to 5? a. if (x == 5) b. if (x = 5) c. if (x <= 5) d. if (x >= 5)


Set pelajaran terkait

Similarity, Similar Figures, Similar Figures

View Set

CH 7 - Escrows and Title Insurance

View Set

Sadlier-Oxford Vocab Level H - Unit 1

View Set

Security + 501 Chapter 5 Risk Management

View Set

Ch 39 Nursing assesement: GI practice questions

View Set

Amboss Rheumatology and Immunology

View Set