Computing HW 1

Ace your homework & exams now with Quizwiz!

Given the following code fragment and the input value of 2.0, what output is generated? double tax; double total; printf("Enter the cost of the item:\n"); scanf("%lf", &total); if (total >= 3.0) { tax = 0.10; printf("%lf\n", total + (total * tax)); } else { printf("%lf\n", total); }

2.0

What is the value of x after the following statements? int x; x = 15%4

3

What is the value of x after the following statements? int x; x = 15 / 4;

3

What is the value of x after the following statements? double x; x=15/4

3.0

Another way to write the value 3452211903 is ____.

3.452211903e09

What is the value of x after the following statement? double x; x = 3.0 / 4.0 + 3 + 2 / 5;

3.75

What is the value of x after the following statements? int x; x = 0; x = x + 30;

30

What is the output of the following code? int value; value = 33; printf("%d\n", value);

33

What is the value of x after the following statemetns? int x, y, z; y = 10; z = 3; x = y * z + 3;

33

Given the following code fragment, what is the output? int x = 5; if (x > 5) printf("x is bigger than 5. "); printf("That is all. "); printf("Goodbye.\n");

That is all. Goodbye.

What is the output of the following code? printf("This is a \\");

This is a \

The body of a while loop may never execute.

True

What is the correct way to write the condition y < x < z?

((y<x) && (x<z))

____ is the decimal number 42 converted to an 8-bit binary number using 2's complement notation.

00101010

What is the value of x after the following statement? double x; x = 3.0 / 4.0 + (3 + 2) / 5;

1.75

Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while (x <= 3) { y += 2; x += 1; }

10

What is the value of x after the following statements? double x; x = 0; x += 3.0 * 4.0; x -= 2.0;

10.0

____ is the decimal number -42 converted to an 8-bit binary number using 2's complement notation.

11010110

Given the following code fragment and the input value of 4.0, what output is generated? double tax; double total; printf("Enter the cost of the item:\n"); scanf("%lf", &total); if (total >= 3.0) { tax = 0.10; printf("%lf\n", total + (total * tax)); } else { printf("%lf\n", total); }

4.4

____ is the decimal number associated with the ASCII character '0'.

48

Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while (x < 3) { y += 2; x += 1; }

8

Loops are used when we need our program to make a choice between two or more things.

False

The braces for a loop define the ____ of the loop.

body

Executing one or more statements one or more times is known as ____.

iteration

Which of the following is NOT legal? char ch = 'b'; char ch = 65; char ch = "cc"; char ch = '0';

char ch = "cc";

The format specifier used to tell printf to expect an integer is a percent sign followed by the character(s) ____.

d

A loop that always executes the loop body at least once is known as a ____ loop.

do-while

Every line in a program should have a comment.

false

If x has the value of 3, y has the value of -2, and w is 10, is the following condition true or false? if (x < 2 && w < y)

false

The integer 0 is considered true.

false

The opposite of less than is greater than.

false

Variable names may begin with a number.

false

The portion of the printf function call within the double quotes is called the ____.

format string

What is the value of x after the following statements? int x; x = x + 30;

garbage as x not initialized

Given the following code fragment, which of the following expressions is always true? int x; scanf("%d", &x); if ((x/3)>1) if (x<3) if (x==1) if (x=1)

if (x=1)

What is the final value of x after the following code fragment executes? int x = 0; do { x++; } while (x > 0);

infinite loop

Each time a loop body executes is know as a(n) ____.

iteration

Given the following code fragment and an input value of 5, what is the output? int x; printf("Enter a value\n"); scanf("%d", &x); if (x < 3) { printf("small\n"); } else if (x < 4) { printf("medium\n"); } else if (x < 6) { printf("large\n"); } else { printf("giant\n"); }

large

The format specifier used to tell printf to expect a double-precision floating-point number is a percent sign followed by the character(s) ____.

lf

When must we use braces to define the body of a conditional expression?

multiple statements

if-else statements that are inside other if-else statements are said to be ____.

nested

Is printf used for input or output?

output

Which of the following is not a valid identifier? myInt return myInteger total3

return - keyword

Which of the following lines correctly reads a value from the keyboard and stores it in the integer variable named myInt? scanf("%d", myInt); scanf("%d\n", myInt); scanf("%d", &myInt); scanf("myInt");

scanf("%d", &myInt);

In a compound logical and (&&) expression, the evaluation of the expression stops once one of the terms of the expression is false. This is known as ____ evaluation.

short circuit

Which of the following is a valid identifier? three_com dollar$ 3com 3_com 3-com

three_com

After the following code fragment, x has the value of 3. int x = 3;

true

It is legal to declare more than one variable in a single statement.

true

The body of a do-while loop always executes at least once.

true

What is the output of the following code fragment? int x = 0; while (x < 5) printf("%d\n", x); x++; printf("%d\n", x);

unending list of 0's

What is the output of the following code? int value; value = 33; printf("value\n");

value

int myValue; is called a ____.

variable declaration

Write the loop condition to continue a while loop as long as x ix negative.

while (x < 0)

What is the opposite of x < 20 && x > 12?

x >= 20 || x <= 12

Given the following code fragment and an input value of 0, what is the output that is generated? int x; printf("Enter a value:\n"); scanf("%d", &x); if (x = 0) { printf("x is zero\n"); } else { printf("x is not zero\n"); }

x is not zero

Given the following code fragment and an input value of 3, what is the output that is generated? int x; printf("Enter a value\n"); scanf("%d", &x); if (x = 0) { printf("x is zero\n"); } else { printf("x is not zero\n"); }

x is not zero

What is the correct conditional statement to determine if x is between 19 and 99 (both ends exclusive)?

x>19 &&x<99


Related study sets

[Sociology] Chapter 16: Education

View Set

Chapter 5 - Citizenship and the Constitution

View Set

EAQ Pharmacology: Diabetes Drugs

View Set

Final Exam - every study guide combined into 1 (missing 7/23 lecture)

View Set

Unit 22 Investing in Real Estate

View Set