geo lab

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which one is a legal character, not a string? 'this' 't' "or this" "this"

't'

The array in C++ starts counting from: 0 2 1

0

Which of the following are correct values for the numeric data types? Select all that apply 1000 'abc' "hello" 3.14

1000 3.14

Which of the following expressions are legal in C++? 12 + "Mike" 12 + 4 "hello" + 11 "hello" * 3.14

12 +4

Characters

A char variable holds a 1-byte integer. However, instead of interpreting the value of the char as an integer, the value of a char variable is typically interpreted as an ASCII character. A character is enclosed between single quotes (such as 'a', 'b', etc). For example: char test = 'S';

Strings & Characters (In C++, single quotation marks indicate a character; double quotes create a string literal. While 'a' is a single a character literal, "a" is a string literal.)

A string is composed of numbers, characters, or symbols. String literals are placed in double quotation marks; some examples are "Hello", "My name is David", and similar. Characters are single letters or symbols, and must be enclosed between single quotes, like 'a', 'b', etc.

Arrays

An array is used to store a collection of data, but it may be useful to think of an array as a collection of variables that are all of the same type. Instead of declaring multiple variables and storing individual values, you can declare a single array to store all the values. When declaring an array, specify its element types, as well as the number of elements it will hold. int a[5]; In the example above, variable a was declared as an array of five integer values [specified in square brackets]. You can initialize the array by specifying the values it holds: int b[5] = {11, 45, 62, 70, 88}; The values are provided in a comma separated list, enclosed in {curly braces}.

Booleans

Boolean variables only have two possible values: true (1) and false (0). To declare a boolean variable, we use the keyword bool. bool online = false; bool logged_in = true;

The result of the 'a && b' is true if: Both a and b are true Either a or b is true Both a and b are false

Both a and b are true

Data types are intended to: Define a loop or an if statement Define header file name Define the proper use of an identifier

Define the proper use of an identifier

The result of a || b is true if (select two answers): Select all that apply Both a and b are true Neither a nor b is true Either a or b is true

Neither a nor b is true Both a and b are true

Booleans

The Boolean data type returns just two possible values: true (1) and false (0).

The OR Operator (You can combine any number of logical OR statements you want. In addition, multiple OR and AND statements may be chained together.)

The OR (||) operator returns true if any one of its operands is true.

Logical NOT(Be careful using this, because !false means true.)

The logical NOT (!) operator works with just a single operand, reversing its logical state. Thus, if a condition is true, the NOT operator makes it false, and vice versa.

The Return Type

The main function takes the following general form: A function's return type is declared before its name. In the example above, the return type is int, which indicates that the function returns an integer value.

Data Types

The operating system allocates memory and selects what will be stored in the reserved memory based on the variable's data type. The data type defines the proper use of an identifier, what kind of data can be stored, and which types of operations can be performed.

Which of the following is true for the switch statement? The switch statement may be an alternative for multiple if statements The switch statement must always contain a default case The switch statement is the same as the for loop

The switch statement may be an alternative for multiple if statements

Select the correct statements about && and || operators. Select all that apply a && b is false if both a and b are true (a || b ) && c is true if c is true and either a or b is true a || b is true if either a or b is true a && b is true if either a or b is true

a || b is true if either a or b is true (a || b ) && c is true if c is true and either a or b is true

How many && operators can be used in one if statement? As many as you want Only one Two

as many as you want

void

indicates that a function or method does not return a value.

is 3.14 an integer yes ||(or) no

no

Can floating point types hold negative numbers? Yes No

yes


संबंधित स्टडी सेट्स

Zybooks Chapter 12 Files Participation Activity Questions

View Set

Anatomy Chapter 6 Practice Questions

View Set

Prep U - Ch 13 : Nursing Process

View Set

DIT Microsoft Office Basics —- WORKING WITH FILES

View Set

Principles of Marketing Chapter 11

View Set