CSCI 240 - quiz 2

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

1/8

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

9 Terms

1
New cards

What instruction will display data on the screen from a C++ program?

cout

2
New cards

About how many decimal places of accuracy does a float have?

6

3
New cards

The formula for converting a Fahrenheit temperature to Centigrade is 5/9(F - 32). What is wrong with writing it in C++ as

C = 5/9 * (F - 32);

assuming that C and F are both declared as doubles, and F has a valid value.

5/9 will give a quotient of zero. Can be fixed by adding either a .0 to 5 or 9

4
New cards

What is the value of the expression 25 % 3?

1

5
New cards

Explain in detail what the following instruction does (assuming i is declared as int):

cin >> i;

This instruction asks the user to enter a value to be assigned to the variable i

6
New cards

Suppose you have two integer variables (named num and sum) with valid values. Write a single cout instruction to display them as follows:

num is __sum is __

the underscore characters will show the actual values in num and sum - for example:

num is 4sum is 24

cout << "num is " << num << "\nsum is" << sum;

7
New cards

Name two libraries that should be #include'd at the top of a C++ program.

<iostream>

<iomanip>

8
New cards

Assuming that two floating point numbers have been saved in the variables num1 and num2, write a chunk of program code that will display the integer result of the sum of num1 and num2. For example, if num1 contains 2.4 and num2 contains 2.5, then the value 4 should be displayed.

int sum;

sum = num1 + num2;

cout << sum;

9
New cards

Write a chunk of program code that asks the user to enter two floating point numbers and saves the values in two float variables called val1 and val2.

float val1, val2;

cout << "enter a value: " << endl;

cin >> val1;

cout << "enter another value: ";

cin >> val2;