QUIZ 1

Ace your homework & exams now with Quizwiz!

In C assuming a variable called "pointer" points to a valid character, what is the syntax to obtain that character?

*pointer

Convert to hexadecimal: 0000 1100 0000 1111 1111 1110 1110 0000

0x0C0FFEE0

Assuming a 4 bit unsigned word, convert the binary number 1111 to hexadecimal:

0xF

stderr is used to display what two kinds of messages:

1. Error 2. Debugging

What sequence of keystrokes causes CSE 12 programs to terminate normally:

CTRL D

"using namespace" in C++ is most similar to what keyword in Java

Import

Is the array parameter to your writeline method in hw1 an input or an output parameter or both?

Input

Assuming 0xFF is stored in a signed char, it the number positive or negative?

Negative

In your basout function, when processing a small positive number, you have a loop of processing that number terminating when what condition is met?

Quotient is 0

T or F: Casting is overridding the type assignment of the compiler

T

Is 0 of type void pointer?

Yes

An output statement to standard error starts with what word in C++?

cerr

An output statement to standard output starts with what word in C++?

cout

Assuming a variable called "variable" exists in your program, what is the syntax to obtain the address of where "variable" exists in memory?

&variable

As a signed integer, the bit pattern 0xFFFFFFFF is more commonly known as:

-1

Write the decimal value that represents all 1s for 32 bits as a signed value

-1

In C and C++, what is the number value of NULL?

0

In C and C++, what is the number value of false?

0

Convert 0x5 to binary:

0101

Convert to hexadecimal: 0000 1111 1110 1110 1101 1101 1010 1101

0x0FEEDDAD

Assuming a 4 bit unsigned word, convert the binary number 0101 to hexadecimal:

0x5

What is the hexadecimal value for the largest signed positive number that can be stored using 32 bits?

0x7FFFFFFF

Assuming a 4 bit unsigned word, convert the binary number 1000 to hexadecimal:

0x8

Write the hexadecimal value that represents all 1s for 32 bits

0xFFFFFFFF

How long do you have after a graded program or quiz is returned to you for you to raise issues about the grading on that program or quiz?

1 week

How long does a faculty member at UCSD have to easily make a correction to an assigned course grade?

1 years

List two situations that cause the standard output buffer to be displayed to the screen when running a C program?

1. Newline is requested (common) 2. Ask for input (common) 3. Program terminating normally (uncommon) 4. Buffer gets full (uncommon) 5. Explicit flush (uncommon)

Assuming the following line of code in C executed, list one situation where the string is not displayed to the user: fprintf (stdout, "Hello World");

1. Runtime error 2. Infinite loop

In our focus in CSE 12, what are the four main sections of memory:

1. Text 2. Data 3. Heap 4. Run time stack (RTS)

Convert 0x9 to binary:

1001

Convert 0xa to binary:

1010

Convert 0xd to binary:

1101

What is the length of the string "ABC"?

3

How many binary digits are needed to represent one hexadecimal digit?

4

In C, what is the minimum character array size need to store the string: "ABC"?

4

What is the type of 0?

All types

In terms of the analogies discussed in class regarding pointers and phone numbers, what is the phone number equivalent to a getting the address of a variable?

Ask someone for the phone number

Professional interactions involve what basic criteria.

Benefits to me

What is the unit of allocation for the parameter sent to "malloc"?

Byte

In what section of memory do global variables exist:

Data

In what section of memory do static variables exist:

Data

In Java, C or C++ code, when a number begins without a prefix, what do you know about that number: (example: int zzz =12;)

Decimal

When you place an asterisk (*) before a pointer variable, what are you doing?

Deference

What can't you do with a void pointer?

Dereference

What is the term for going to where a pointer points?

Dereference

T or F: Control-D input works the same whether stdin is empty or not.

F

T or F: For full credit in CSE 12, if a function/method body has only one line of code, a function/method header isn't needed.

F

T or F: For full credit in CSE 12, if you didn't change a file that is part of your assignment, you still need to provide a file header.

F

T or F: For full credit in CSE 12, you should have one inline comment for every line of code in your program.

F

T or F: If your program passes all execution test cases, you will always get full credit for that assignment.

F

When you place an ampersand (&) before a variable, what are you doing?

Getting the address

What is displayed to the terminal by the following C code: writeline ("Hello World ", stdout); writeline ("Goodbye World ", stderr);

Goodbye World Hello World

Dynamic memory allocation allocates from what section of memory?

Heap

The malloc function returns a pointer into what section of memory?

Heap

What is displayed to the terminal by the following C code: writeline ("Hello World ", stderr); writeline ("Goodbye World ", stdout);

Hello World Goodbye World

In Java, C or C++ code, when a number begins with a leading 0x, what do you know about that number: (example: int zzz =0x12;)

Hexadecimal

Assuming the user inputs a short valid string, in your getaline function, you have a loop of processing characters terminating when processing what character:

Newline character

Assuming the user inputs a valid number, in your decin function, you have a loop of processing characters terminating when processing what character:

Newline character

What character is the last one entered in every user response in C, C++ and Java when reading from standard input:

Newline character

If asking for a regrade with a potential gain of 1% or more of your course grade, are you risking a deduction to your professionalism?

No

If asking for a regrade with a potential gain of <1% of the course grade after the grades appear on TritonLink when those points can change your grade, are you risking a deduction of your professionalism?

No

If asking for clarification about point deductions where the grading comments are insufficient, are you risking a deduction of your professionalism?

No

Should you store the newline character as part of the string formed by getaline?

No

What is the effect on the stdin buffer when the only the following keystrokes are entered: A B backspace

No effect

In C and C++, what is the number value of true?

Not 0

Besides wanting the memory to exist beyond the execution of the function that created it, what the the other main situation discussed in class when you must dynamically allocate memory in C and C++?

Not knowing how much memory you need.

What character exists at the end of all strings in C and C++:

Null character

In C, in your writeline function, you have a loop of printing characters terminating when processing what character: Should you print a NULL character in writeline?

Null character No

In Java, C or C++ code, when a number begins with a leading 0, what do you know about that number: (example: int zzz = 012;)

Octal

Is the array parameter to your getaline method in hw2 an input or an output parameter or both?

Output

What word best describes when adding two positive numbers give a negative result?

Overflow

In terms of the analogies discussed in class regarding pointers and phone numbers, what is the phone number equivalent to a pointer dereference?

Phone call

In terms of the analogies discussed in class regarding pointers and phone numbers, what is the phone number equivalent to a pointer declaration?

Phonebook entry

What is the one best word to describe an unsigned value in C or C++?

Positive

In what section of memory do local variables exist:

Run time stack (RTS)

In what section of memory do parameters exist:

Run time stack (RTS)

When does dynamic memory allocation occur?

Runtime

How does the parameter to "free" relate to the return value of "malloc"?

Same

T or F: For all programming assignments, you need to run turnin.

T

T or F: For full credit in CSE 12, all inline comments need to be at the same indent level as the code being documented.

T

T or F: For full credit in CSE 12, descriptions of the algorithm for a method/function normally belong in the "Description" field of a function/method header.

T

T or F: For full credit in CSE 12, for file, class/struct and function/method headers, as long as the content is complete, you can follow a header style of your choice.

T

T or F: For full credit in CSE 12, if a file contains only one class or struct definition, you can have a combined file and class/struct header as long as all information is present.

T

T or F: For full credit in CSE 12, implementing a method for a class or struct mean that you need to have a class/struct header.

T

T or F: For full credit in CSE 12, you should have one inline comment for every idea that you implement in your program.

T

T or F: For full credit in CSE 12, your inline comments should justify the existence of code that follows.

T

T or F: For full credit in CSE 12, your name always belongs in the file header for those files that you authored or updated.

T

T or F: For full documentation credit in CSE 12, you need to have a comment describing the purpose of every declared variable, object and data field that you declare.

T

In what section of memory do if statements exist:

Text

Under what circumstance can you wait longer than one week to raise issues about the grading on a program or quiz?

The points could change your overall grade.

When the standard input buffer is empty and your program calls fgetc, what is the resultant behavior of your program:

The program waits for input.

Besides not knowing how much memory you need, what the the other main situation discussed in class when you must dynamically allocate memory in C and C++?

Wanting the memory to exist beyond the execution of the function that created it.

If asking for a regrade with a potential gain of 1 homework point, are you risking a deduction of your professionalism?

Yes

Is 0 of type int pointer?

Yes

Should you store the NULL character as part of the string formed by getaline?

Yes

What is a void pointer?

a pointer to nothing/anything

What is the syntax in C to declare an uninitialized character pointer variable called "pointer"?

char * pointer;

An input statement from standard input starts with what word in C++?

cin

What is the keyword used to dynamically deallocate memory in C++?

delete

What is the C function to give back dynamically alloced memory?

free

In the following assignment in C, what is the type of the "character" variable: character = fgetc (stdin);

int

What two commands must you enter at the UNIX command line from the ~/../public/hw2 directory to begin working on hw2?

make directories make install

What is the C function to dynamically allocate memory?

malloc

What is the keyword used to dynamically allocate memory in C++?

new

What is the keyword used to dynamically allocate memory in Java?

new

What is the return type of "malloc"?

void pointer

What is the type of the parameter to "free"?

void pointer


Related study sets

Beneficiaries and settlement options

View Set

Animation Assessment: Chemical Synapses

View Set

PSY 340 Chapter 11-16 Comprehension

View Set

6th grade Chapter 16, section 4-The Empire of Alexander the Great- Amazing, read this. Give me some hi 5s go to info and put Ur cusrer over the hi 5 thing

View Set

(Notes) 240>Fine Arts/Health/PE>Fine Arts>Music

View Set

Chapter 7: Business Strategy: Innovation, Entrepreneurship, and Platforms

View Set

BIOL 207 Exam 1 Review Questions

View Set