CPSC 1010 exam questions MC

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following is an example of a run-time error? A: forgetting a semi-colon at the end of a statement. B: attempting to divide by zero C: attempting to use a variable that hasn't been declared yet

Attempting to divide by zero

When a compiler says that an error exists on line 5, that line must have an error. (True or False)

False

_Bool x = 1, y = 0; What value would this expression have? !(y || !(y && x))

False (might need to brush up on this stuff)

This person was the one who had the idea that programs could be written in more English-like statements than assembly language and machine language; also created the first compiler.

Grace Murray Hopper

Which of the following is the proper way to include the stats.h file in the other files that need it?

#include "stats.h"

Show what will be printed by the printf() statement: int i = 7, j; j = i % 3; printf("%d", j);

1 (% operator gives the remainder)

What is the output of this simple program with a "for" loop? for (i = 1; i < 4; i++){ printf("%i ", i); }

1, 2, 3

Show what will be printed by the printf() statement: int r = 9, s; s = ++r + 2; printf("%d", s);

12 (because the ++ is before the r, you do that first, so on line 2 its just 10 + 2)

Show what will be printed by the printf() statement: int a = 12; printf("%d", a += 3);

15

A compiler warning by default will prevent an executable from being created. (True or false)

True

These are the (low-level) types of instructions that the computer (processor) understands. They are not human readable; they are machine dependent - only worked on the machine that it was developed for (i.e. not portable).

machine language instructions

There are steps to program development, beginning with creating an algorithm and then opening up an editor and typing up code. Which of the following show the rest of the steps in the correct order:

pre-processor, assembler, linker, loader

int s = 8, t = -2; what value would this expression have? !( (s >= -3) && !(t <= 0) )

true

for (i = 4; i > 0; --i) { printf("%i", i); } printf(" - "); for ( ; i < 5; ++i) { printf("%i", i); }

4321 - 01234 (the zero is there because after the last iteration of the first loop, it still has to negatively incrememnt i, from 1 to 0)

Show what will be printed by the printf() statement: int d = 8, e = 2, f = 3; printf("%d", ((-f + 5) * e) / (20 / d));

2 (pemdas)

Show what will be printed by the printf() statement: int g = 7, h = 3; printf("%.3f", (float)g / h);

2.333 (the .3f means go three decimal places)

Show what will be printed by the printf() statement: int b = 4, c; c = b++; printf("%d", c);

4 (the ++ came after, so you increment that after assinging the value of b(4) to c)


Conjuntos de estudio relacionados

Path Ch.38 Disorders of Special Sensory Function

View Set

LEGL-2064 - Chapter 14, Section 4: Sales and lease contracts

View Set

Business communication study guide 8

View Set

Lesson 5: Pressure, Winds and Circulation

View Set

Lippincott Gastrointestinal Tract - Chapter 13

View Set