CSE 2421 - Systems 1 Exam 1 Review

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

True

A block in ANSI C can legally be empty

Memory leaks

A condition where the memory used by the program may grow potentially without bound

True

A const keyword variable must be initialized as part of the declaration

Nibble

A group of 4 bits at a time

spaces

BASH uses ______ as a a tokens separator

True

C allows direct manipulation of memory

\r

Carriage return character

\f

Formfeed character

True

In ANSI C, all variable declarations in the block must precede the first non-declarative statement (ie no-just-in-time declaration in C)

Machine code

Is C fully compiled to machine code or byte code

Procedural

Is C procedural or object-oriented

Invalid

Is ca$h a valid identifier name?

Yes (keep in mind that both Unix/linux use the _ to start many variable names)

Is the identifier name _counter valid?

\n

New line character

.o

Object files that the computer reads use what extension

\ooo

Octal number character

True

The pre processor prepares a .c file for the compiler

Precedence

The relationship between two operators in terms of the order in which the operations are preformed

True

There are 2 basic data types in C: integer data types and floating point data types

False (The potential derived types made from basic types is infinite)

There is no way to create any data types other than the 2 basic data types

0101

a = 10 = 1010 What is ~a

1010

what is a ^ c a = 10 = 1010 c = 0 = 0000

1010

what is a | c a = 10 = 1010 c = 0 = 0000

1011

what is a | c a = 10 = 1010 c = 1 = 0001

1011

what is a | c a = 10 = 1010 c = 3 = 0011

0000

what is a&c a = 10 = 1010 c = 0 = 0000

0000

what is a&c a = 10 = 1010 c = 1 = 0001

0010

what is a&c a = 10 = 1010 c = 3 = 0011

1101 0100

x = 0111 0101 What is x << 2

1111 1101

x = 1111 0101 Arithmetic x >> 2

0011 1101

x = 1111 0101 Logical x >> 2

\\

Backslash character

\xhh

Hexadecimal number character

\t

Horizontal tab character

The compiler ignores them

How is white space (tabs/newlines/returns, spaces, etc.) handled within a C program file?

8

How many bits are in one byte?

8

How many bits is a char

64

How many bits is a long

128

How many bits is a long long

16

How many bits is a short

32

How many bits is an int

8

How many bytes is a double

16

How many bytes is a long double

4

How many bytes is a single precision floor at

Style

IS an identifier name of camelBack a requirement or a style (i.e. do we have to capitalize?)

True

Preprocessor takes input from sourcecode.c and output goes to sourcecode.i

True

Preprocessors replace any MACROs

True

Preprocessors strip all comments from .c files

\?

Question mark character

-2^(w-1) to 2^(w-1)-1

Range of binary two's complement (B2T)

Arithmetic shift

Shift used when interpreting as signed values

Logical Shift

Shift used when interpreting as unsigned values

\'

Single quote character

.c

Source code files in Unix/Linux have what extension

0 to (2^w)-1

What is the range of integers in unsigned binary (B2U)

After

a++ is when a is incremented ________ a is evaluated in the expression

It was developed to create the UNIX system.

Why was the C programming language initially created?

Valid

is printf a valid identifier name?

1 11 3 1 12 -1 5 11 -2 5

#include <stdio.h>int main() { int z, a=10, b=0, c=3; z = (++a > b) || (++a < c++); printf("z = %d, a = %d, c = %d\n", z , a, c); /* 1. z= HERE a= HERE c= HERE */ c = 30; z = (a > c) || (++a > --b); printf("z = %d, a = %d, b = %d\n", z, a, b); /* 2. z= HERE a= HERE b= HERE*/ a = 10; c=3; z = ++a + --b * c++; printf("z = %d, a = %d, b = %d, c = %d\n", z, a, b, ++c); /* 3. z=HERE , a= HERE, b = HERE, c = HERE */ return(0); } Enter answers separated by a single space, there should be 10 answers

Before

++a is when a is incremented _________ a is evaluated in the expression

both return type and parameter information

A function declaration contains: - no return type information, just parameter information -both return type and parameter information - no return type or parameter information - return type info, bur no parameter info

return type and parameter information plus code body

A function definition contains: - no return type information, just parameter information - no return type or parameter infor - return type info, but no parameter infor - return type and parameter information plus code body

Type information only, no initial value

A variable declaration contains: - both type and initial value information - no value or type information - type information only, no initial value - no type information, only an initial value

both type and initial value information

A variable definition contains: - both type and initial value information - no value or type information - type information only, no initial value - no type information, only an initial value

True

ANSI C does not have a Boolean type

#

ANSI C preprocessor directives begin with: - // - # - /*

False (Classes and Objects are C++ constants, not C constructs)

ANSI C supports the notion of Classes and Objects

\a

Alert (bell) character

True

All L-Values must be modifiable since they are assigned a value

False (functions have file scope in C)

All functions have block scope

Both logic errors and division by zero

An example of a dynamic error is: - Both logic errors and division by zero - Division by zero - Syntax error - Logic error -Both Syntax and logic errors

Syntax Error (A static error would either be a syntax error or a linking error)

An example of a static error is: - Incorrect file name - Syntax error - Division by zero

No

Are any two identifier names that are identical for the 1st 31 chars a good choice?

\b

Backspace character

False

C has garbage memory collection

Function

C statements grouped into a single logical unit

True

Const variables are treated as read-only variables

\"

Double quote character

Compile time

Events that can occur when a program is being compiled or built

Run time

Events which can occur when the program is being executed or running

True (This is true and similar to the requirement that a C++ program must have one main() method.)

Every C program must have exactly one function called main()

Macros

Fragments of code, defined in the source file, or in a header file, with the code they are defined to represent Created with the #define preprocessor directive

File scope

If a function is declared in a file, that function can be used anywhere within the file after it is declared. - declaring a function - block scope - file scope - false

file1 file2 file3

If the command line says: lab1 < file1 >file2 2>file3 then, stdin comes from ANSWER stdout goes to ANSWER stderr goes to ANSWER

file1 Screen Screen

If the command line says: lab2 <file1 then, stdin comes from ANSWER stdout goes to ANSWER stderr goes to ANWSER

Keyboard file1 file2

If the command line says: lab3 >file1 2>file2 then, stdin comes from ANSWER stdout goes to ANSWER stderr goes to ANWSER

file1 screen file2

If the command line says: lab4 <file1 2>file2 then, stdin comes from ANSWER stdout goes to ANSWER stderr goes to ANWSER

keyboard file1 file1

If the command line says: lab5 > file1 2>&1 then, stdin comes from ANSWER stdout goes to ANSWER stderr goes to ANWSER

keyboard file1 screen

If the command line says: lab6 2>&1 > file1 then, stdin comes from ANSWER stdout goes to ANSWER stderr goes to ANWSER

keyboard file1 file 2

If the command line says: hello >file1 2>file2 then, stdin comes from ANSWER stdout goes to ANSWER stderr goes to ANSWER

False

If we can redirect stdin when running a program within gdb we are redirecting input for both the program and all gdb instructions we want to execute

True

In ANSI C, all declarations in a block must precede the first non-declarative statement

Valid (may truncate after 31 chars)

Is California_Emission_Control_Baseline a valid identifier name

No (It's not a keyword, because C identifiers are case sensitives, but it could be confusing)

Is GoTo a good choice for an identifier name?

Style

Is an identifier name of Avg_Val a requirement or a style? (ie. are you require to use _?)

No (Identifiers in C can not contain spaces)

Is avg value a valid identifier name?

Yes (It has to be valid or we couldn't use it as a function name)

Is main a valid identifier name?

True

Modern computers store and process information as two-valued signals (off/on, true/false, 0/1)

Linux has 60-100 viruses listed compared to the 85-120 viruses listed for UNIX

Name another difference between Unix/Linux from your required reading.

True

Nest blocks are valid in C, but nested functions are invalid

False

The ANSI C compiler will treat two variables, named val and Val in a C program as the same variable.

While open source systems don't always cost money to purchase the license, it can cost money to purchase the hardware needed to run the system. Also, it takes time to learn and set up open source systems, which can cost you time. Server versions for open source systems also cost money, but this is for support contracts, not the software.

UNIX is proprietary system (i.e. you must purchase a license) while Linux is an Open Source system. An Open Source system, however, is not always "free". Why?

Arrays, pointers, structures, unions, plus the ability to use each of these vehicles recursively

Vehicles to create derived types are: - There is no ability to derive more types - Arrays, pointers, structures, unions, - Arrays, pointers, structures, unions, plus the ability to use each of these vehicles recursively

\v

Vertical tab character

True

We can redirect input to a program that we are running within gdb

Gdb

What C device allows you to: - watch your program run instruction by instruction - observe a variable change values and see when things you thought should happen don't - Give you opportunities to fix them within your code with significantly less effort

Declarations, data movement, arithmetic/logical operations, control-flow

What are the four general categories of Statements in Computer languages

Function prototypes

What do head files usually contain

The data display debugger

What does DDD stand for

The GNU Debugger

What does Gdb stand for

It tells us the number of lines of code that is in the file.

What does the wc -l instruction do? The manual page for that instruction says prints the newline count, but what important information does that count tell you?

.h

What is the extension of a header file

ASCII digits have a value 48 greater than what they represent

What is the relationship between the ASCII value of a digit and the actual value it represents?

UNIX was built around a kernel using "code recycling features," which allowed it to be more easily adapted to different types of hardware compared to other software systems.

What made UNIX different from all other commercially available software systems when it was initially developed?

LINUX

What operating system covers the widest range of hardware in the world?

False (the line that is printed out by gdb is the line that will be executed next.)

When a line of code is printed out after the next command in gdb, that line of code has just finished executing. True or False?

While running the program during testing (This is the first time that a dynamic error can be found)

When can a dynamic error first be found? - While running the program during testing - At compile time - Only after the program is deployed to a customer's location

At compilation time (Static errors can only occur during compilation)

When can a static error first be found? - At compilation time - Only after the program is deployed to a customer's location - While running the program during testing

Short circuit evaluation

When relational statements stop evaluating once a statement's value is definitive

it is a function declaration that terminates with a ';'

Which of the following is true with respect to a prototype statement: -it is a function declaration that includes code -it is a function declaration that terminates with a ';' -it is a function definition that terminates with a ';'

False (It's a reserved word so it can't be used)

goto is a valid identifier name

10 x z 14 arr1[3]

int x=10, y=20, z = 30; /* What do the statements below do? */int arr1[ 20]; int *int_ptr1, int_ptr2; int_ptr2 = arr1; int_ptr1 = &x; y = *int_ptr1; /* 1. Replace *int_ptr1 with a number, so y=HERE */ *int_ptr1 = 0; /* 2. Replace *int_ptr1 with an identifier, so HERE=0 */ int_ptr1 = &z; *int_ptr1 = 15; /* 3. Replace *int_ptr1 with an identifier, so HERE=15 */ x = *int_ptr1-1; /* 4. Replace *int_ptr1 with a number, so x=HERE */ *(int_ptr2+3) = x; /* 5. Replace *(int_ptr2+3) with an identifier,so HERE= x */ Reminders: * in a declaration says "I am a pointer" that points to a certain type of value & means "address of" * (on the right side of an assignment) means "get/read the value at that address" * (on the left side of an assignment) means "set/write the value at that address" Answers should be separated by 1 space

Invalid (In C, an identifier cannot start with a number)

is 123 a valid identifier name?

invalid (Identifiers in C cannot contain *)

is a*b a valid identifier name


Kaugnay na mga set ng pag-aaral

Penny Review : Fetal Face and Neck

View Set

Penal Code 3 - TCOLE Objectives 8.24 - 8.34

View Set

Anatomy Chapter 5 The Skeletal System

View Set

Introduction to Concepts and Responsibilities of Home Ownership

View Set

Marketing Final (Ch 13 + All Quizzes)

View Set

ET3P4: Firms in a competitive market

View Set

Manufacturing Exam 1 Chapter 1-8

View Set

Chapter 9; Psychological Disorders

View Set