CS1313 final (homework)

Ace your homework & exams now with Quizwiz!

GIVE AN EXAMPLE of a character string literal constant.

"This is a printf.\n"

NAME TWO EXAMPLES of optical secondary storage media, and give an advantage and a disadvantage of each.

DVD and CD Advantage: always can be read Disadvantage: some can be written only once Advantage: cant be erased by magnets Disadvantage: contents degrade e.g. being scratched

WHICH of the above four things does the statement below cause to be set? float y = 22.7;

Data type, value, name, and address

WHAT is compile time?

Things that occur while a program is being compiled

WHAT is runtime?

Things that occur while the program is running

Is an assignment an ACTION or an EQUATION?

action

NAME THREE EXAMPLES of operating systems

android Microsoft windows Mac OS

WHERE in a program is the declaration section?

at the beginning of program after the open block

If I compile a C source file named my program.c on ssh.ou.edu, which has an Intel x86 processor, and I give the executable my program to you to run on OU's super- computer, schooner.oscer.ou.edu, which also has an Intel x86 processor, will you be able to run it properly? EXPLAIN.

because of the similar computer architecture, if the system runs the same assembly language then theoretically it could

NAME TWO DIFFERENCES between a bit and a byte.

bytes are addressable whereas a bit isn't bytes are a collection made up of 8 bits

WHICH KEY on the keyboard will cause a new line to appear when you are typing? (NOTE: This question ISN'T asking about a newline inside a character string literal constant.)

enter

Some compilers on some computers automatically initialize newly declared variables to de- fault values. UNDER WHAT CIRCUMSTANCES should you explicitly initialize or assign a value to a variable, rather than letting the compiler initialize it to the default value?

you should always assign values to your variables, never assume that the compiler will initialize variable for you

DEFINE the word delimit.

Limit determiner

In the word MULTICORE, what does "core" refer to?

The independent "brains'

WHAT is a character string literal constant?

Sequence of characters deliited by " at the beginning and " at the end

WHAT is source code?

Sequence of instructions, written in human-readable programming

WHAT does an assignment statement do?

Sets contents of specific variable to specific value

WHICH of the above four things does the statement below cause to be set? int x;

Sets contents of specific variable to specific value

NAME a device that does BOTH input and output (you are not limited to the ones listed in the lecture notes, but your choice must fit the definition).

Smart phone

WHY do we use comments?

So when the program is revisited the intent and purpose is readable and can be understood by the programmer

In an assignment, ON WHICH SIDE OF THE SINGLE EQUALS SIGN is the value that the variable is being set to?

right side

HOW MANY different possible values can a set of 8 bits have?

0 to 255 or -128 to 172

WHAT IS THE NAME of each of the following C constructs: /* */ /* What is this? */ { } #Include <stdio.h> int main () printf("Hello, world!\n");

start of comment, comment delimiter end of comment, comment delimiter comment start of block, block open end of block, block close preprocessor directive main function header printf statement

How is standard input ABBREVIATED in writing?

stdin

How is standard output ABBREVIATED in writing?

stdout

NAME A DIFFERENCE between compilers and assemblers.

A compiler turns human-readable high-level code to machine readable. Assemblers convert human-readable assembly code to machine readable

WHAT is a declaration (also known as a declaration statement)?

A declaration is a statement tells the compiler that data exists and its properties tells the compiler- choose location in memory, nam, int/float

WHAT is a programming language?

A defined set of rules that specify the programs data and sequence of actions

WHAT is a source file?

A file of source code

For each of the above four things, WHO chooses it?

the name is chosen by the programmer the address is chosen by the compiler the data type is chosen by the programmer the value is sometime chosen by the programmer and sometimes while the program is running

WHAT is the favorite professor rule?

when you name a variable something that is very obvious

GIVE AN EXAMPLE of an assignment statement.

x=5;

YES OR NO: Can a comment be more than one line long?

yes

YES OR NO: Can a statement be more than one line long?

yes

When data and instructions reside in the following kinds of storage, WHEN are they expected to be used?

(a) Registers- data actively being used (b) Cache- data that has just been used or is about to be used (c) Main memory- data the current program will use (d) Secondary storage- data that will be used in the future

NAME TWO THINGS that every main memory location has.

(a) address (b) value

WHAT are the two categories of primary storage that computers typically have?

(a) cache (b) RAM

NAME TWO DIFFERENCES between main memory and cache.

(a) cache is fast while RAM is slow (b) Cache is very expensive whereas RAM is less expensive

WHAT are the two categories of I/O devices that computers typically have?

(a) input devices (b) output devices

NAME TWO DIFFERENCES between magnetic media and solid state media.

(a) magnetic media can be erased by a magnet, solid state media can't (b) solid state media contents don't degrade over time, magnetic media contents do

NAME TWO DIFFERENCES between magnetic media and optical media.

(a) no every type of optical media can be rewritten, magnetic media can (b) optical media can't be erased by magnets, magnetic media can

NAME TWO DIFFERENCES between primary storage and secondary storage.

(a) primary storage holds data/instructions that are being used currently, whereas secondary storage holds data/instructions that will be used in the future (b) primary storage is typically volatile while secondary storage in nonvolatile

NAME AND DESCRIBE each of the three components of a Central Processing Unit.

(a) registers: memory like location where data/instructions are while being used now (b) multicore: chip with multiple independent cores or "brains" (c) storage: where data and instructions reside

WHAT IS THE OUTPUT of each of these programs? If the program has no output, mark NO OUTPUT and then EXPLAIN WHY. If the program does not compile, mark WON'T COMPILE and then EXPLAIN WHY. If the program outputs garbage, mark GARBAGE and then EXPLAIN WHY. If you are not confident of your answer, type in, compile and run the program. If you're stumped, you can try visualizing the program using: http://www.pythontutor.com/c.html#mode=edit (b) #include <stdio.h> int main () { /* main */ printf("\n"); } /* main */ (c) #include <stdio.h> int main () { /* main */ } /* main */

(b) Won't compile, there is a blank line (c) No output, There is no output to be run

HOW MANY different possible values can an individual bit have?

2

Based on Moore's Law, and using 2 years as the doubling period, approximately HOW MUCH FASTER will computers be in 2080 than they are today?

2^30

Based on Moore's Law, and using 2 years as the doubling period, approximately HOW MUCH FASTER will computers be in 2100 than they are today?

2^45

GIVE AN EXAMPLE of a character string literal constant that causes a newline to occur.

Any character string literal constant that is longer than 80 characters

WHERE in a program is that other section

After the declaration section

WHAT is a variable?

An association among a name or address or data type

The word "bit" is a contraction of WHAT PHRASE?

Binary digit

WHAT is the declaration section of a program?

Contains all the program's declarations

WHAT is the SPEED in MB/sec, the MAXIMUM SIZE in GB and the PRICE per MB of the following storage media on a current PC?

Cache 40,000MB/sec, 32MB, $27.0000000/MB RAM 12,5000MB/sec, 3,145,728MB, $0.0055800/MB hard disk 100MB/sec, 15,000,000MB, $0.0000225/MB USB 3 flash drive 625MB/sec, 512,000, $0.0001640/MB CD-RW 7.8MB/sec, 700MB, $0.0006271/MB DVD-RW 32MB/sec, 4,700MB, $0.0000424/MB floppy disk 0.03, 1.44MB,/sec, 1.44MB, $1.9100000/MB

A NEWLINE is also known as a ... ?

Carriage return

What does Moore's Law tell us?

Company speed and capacity double every 24 moths

NAME A DIFFERENCE between compilers and interpreters.

Compilers convert human-readable high level language source code into machine-readable executable program, interpreters convert human-readable high level language code into actions that are immediately preformed

HOW MANY VALUES can a variable take on over the entire duration of a run?

Exactly one value

WHAT IS THE NAME of the other section of a program?

Execution section

NAME TWO EXAMPLES of solid state secondary storage media, and give an advantage and a disadvantage of each.

Floppy disk and flash drive Advantage: always can be read Disadvantage: expensive per MB Advantage: contents don't degrade much over time Disadvantage: can't be erased by magnates

WHY are floppy disks so expensive per MB, compared to CD-RWs and DVD-RWs?

Floppy disks have much less of a demand so fewer are manufactured which makes it difficult to have high fixed costs of running the factory

NAME A DIFFERENCE between high level languages and assembly languages.

High level languages can be used on any computer, assembly language specified to a particular computer

WHAT does a placeholder DO?

Holds place of value of variable

NAME A DIFFERENCE between assembly languages and machine languages.

Humans can read assembly languages, but only machines can read machine languages

HOW MANY VALUES does a variable have at any given moment in runtime? BE VERY SPECIFIC.

Infinite values

WHAT IS THE DIFFERENCE between an input device and an output device?

Input devices transport data in a computer, output devices transfer data out of a computer

WHAT does the term I/O stand for?

Input/output

For each of the following, WRITE A DECLARATION STATEMENT for a variable representing this quantity. For each, you should choose an appropriate data type. The name should comply with the "favorite professor" rule, and should also be a valid C identifier. You DON'T need to initialize the variables. Assume that intvariables and float variables take 4 bytes (32 bits) each. the number of students in CS1313 your height in lightyears (a lightyear is the distance that light travels in a year, which is about 6 trillion miles). a spaceship's speed in inches per century, approximated to three significant figures (as- sume that the spaceship travels at 99% of the speed of light) the number of books on a bookshelf

Int numberOfStudents; Int yourHeightInLightyears; Float=6 trillionMiles; Int spaceshipSpeedInInchesPerCentury; float=inchesPerCentury Int numberOfBooksOnAShelf

GIVE AN EXAMPLE of an initialization statement.

Int x=3;

WHY don't people usually program directly in assembly language?

It cant be used on all computers

WHY don't people usually program directly in machine language?

It is very tedious and error prone

If I compile a C source file named my program.c on ssh.ou.edu, which has an Intel x86 processor, and I give the executable my program to you to run on a tablet computer that has an ARM processor, will you be able to run it properly? EXPLAIN.

No, the assembly languages differ so the program won't execute

WHAT is standard output?

Output to terminal screen

WHAT is an operating system?

Program that manages interactions

NAME three output devices (you are not limited to the ones listed in the lecture notes, but your choices must fit the definition).

Speaker Printer Monitor

WHAT is a program?

Specific, precise, detailed collection of data and sequence of actions on that data

NAME TWO EXAMPLES of magnetic secondary storage media, and give an advantage and a disadvantage of each.

Spinning disk drive and credit cards Advantage: always can be read Disadvantage: contents can degrade overtime Advantage: don't degrade much overtime Disadvantage: can be erased by magnets

How is the abbreviation of standard input PRONOUNCED?

Standard in

How is the abbreviation of standard output PRONOUNCED?

Standard out

WHAT is the name "character string literal constant" sometimes shortened to?

String literal

WHAT is an initialization?

To declare a variable and assign a value in the same statement

WHY do computers have cache storage?

To store instructions and data that have just been used or are about to be used to allow a computer to run faster

WHAT is a data type?

Type of data ether numeric or non-numeric

If a variable is declared but not initialized, and it has not yet been given a value, then WHAT VALUE does it have?

Undefined or "garbage"

WHAT is standard input?

When a user types at a keyboard

Inside a character string literal constant, HOW is a newline indicated? Give the sequence of characters.

\n

CREATE A COPY of an existing file named whoopdedoo.txt that is in your current working directory, so that the copy is named tapioca.txt and is also in your current working directory EDIT an existing text file named want editing.txt that is in your current work- ing directory. EDIT a non-existent text file named want editing too.txt that will be in your current working directory.

cp whoopdedoo.txt nano want_editing.txt nano editing_too.txt

NAME three ways to set the value of a variable.

input assignment initialization

WHAT IS THE PLACEHOLDER for each of these data types?

int %d float %f char %c

GIVE THREE EXAMPLES of data types.

integer floating point

NAME three input devices (you are not limited to the ones listed in the lecture notes, but your choices must fit the definition).

keyboard joystick mouse

EXPRESS the approximate number of bytes in each of these to the nearest power of 10 (that is, as 10x for the appropriate value of x):

kilobyte 10^3 or 1,000 bytes megabyte 10^6 or 1,000,000 bytes gigabyte 10^9 or 1,000,000,000 bytes terabyte 10^12 or 1,000,000,000,000 bytes petabyte 10^15 or 1,000,000,000,000,000 bytes exabyte 10^18 or 1,000,000,000,000,000,000 bytes zettabyte 10^21 or 1,000,000,000,000,000,000,000 bytes yottabyte 10^24 or 1,000,000,000,000,000,000,000,000 bytes

In an assignment, ON WHICH SIDE OF THE SINGLE EQUALS SIGN is the name of the variable whose value is being set?

left side

In C, WHICH CHARACTERS can be at the BEGINNING of an IDENTIFIER such as a variable name?

letter or underscore

WHAT FOUR THINGS does every variable have?

name address data type value

NAME THREE DIFFERENCES between natural languages and programming languages.

natural language can be ambiguous, programming language can't natural language can be flexible, programming language can't natural language can incorporate multiple languages, programming language can't

Are Unix commands part of a C program?

no

YES OR NO: Can a character string literal constant be more than one line long?

no

what are the two categories of storage that computers typically have?

primary secondary

WHAT KIND OF STATEMENT outputs to standard output?

printf

MARK valid C variable names VALID and invalid C variable names INVALID. For invalid C variable names, EXPLAIN WHY they are invalid. (Note that valid means acceptable to the compiler, rather than good programming practice.) number_of_students_in_CS1313 number of students in CS1313 2_to_tango WHAZZAT Huh?

valid invalid, can't have spaces between the words in the variable valid valid Invalid, variable names can't have special characters such as a question mark


Related study sets

Chapter 33: The Microbe-Human Ecosystem

View Set

Study Guide Unit 1: The Parks Movement: Urban Parks & Public Lands LARC 4413 History of Landscape Architecture II

View Set

Ch. 13: The Water-Soluble Vitamins

View Set

Chapter 3: The Global Marketplace

View Set

Compartmentalization, storage of genetic information

View Set

Chapter 1: Introduction to Pharmacology- Concepts and Connections

View Set