CS 1325 EXAM 1

Ace your homework & exams now with Quizwiz!

How do you dereference a pointer?

*ptr = 10

How do you initialize a pointer?

*ptr = 10;

What are C program file names should end with?

.c

What are the phases of compilation-based execution of a C prorgram?

1. Edit 2. Preprocess 3 Compile 4. Link 5. Load 6. Execute

What are some examples of manipulations that is done to the program before compilations?

1. Including other files in the files to be compiled 2. Performing various text replacements 3. Defining various macros

What does a valid identifier in C can consist of?

1. Letters (lower and upper) 2. Underscores 3. Digits

What are the three types of constants?

1. Literals 2. #define preprocessor directives 3. use of the const declaration on a variable

What are good rules for a variable names?

1. Use capital or underscore to create multi word identifiers 2. Abbreviations should be long enough to clearly indicate what is being abbreviated 3. Avoid the use of generic names 4. Don't create several variable names that differ only by one or two characters

What are the three things that we must know how to do before using a pointer?

1. define a pointer 2. initialize a pointer (giving it a value) 3. Dereference a pointer

How many bytes are in a long double?

10 bytes

How many bytes are in a float?

4

How many bits is in a byte?

8

How many bytes are in a double?

8

What happens during the linking phase?

A linker links the object code with the code for the missing functions to produce an executable image

What is a literal?

A literal is a constant value that is written into the program

How many significant figures can a single precision float store?

About 6-7

What is the name of this operator --> '&' ?

Address operator

What does the edit phase of a C program has to be accomplished by?

An editor program

Why can't the object code be executed?

C programs typically contain references to functions defined elsewhere , therefore the object code contains "holes".

What produces the object code?

Compiler

What is a dynamic data structure?

Data structures that can grow and shrink at execution time

T/F: '$' is a valid identifer

False

T/F: C has pass by reference

False, C does not have pass by reference but pass by value only

T/F: C program are typed in with the linker.

False, C program are typed in with the editor and corrections are made if necessary

T/F: A pointer does not need to be defined before they can be used

False, a pointer must be defined before any use

T/F: Character literals are always in double quotes

False, character literals are always single quotes

T/F: After the source code is turned into an object code it is complete and executable?

False, the object code is not complete and not yet executable

What is a preprocessor directives?

Indicates that certain manipulations are to be performed on the program before compilation

'*' is a _______ operator

Indirection operator or dereferencing operator, is applied to a variable outside of a declaration and returns the value of the object to which its operand points

What happens in C11 when you use the nullptr keyword?

Initialized the pointer to 0

What does the loader do?

Takes the executable image from disk and transfer it to memory

What executes the object code?

The CPU

What does a pointer contain?

The address of a variable that contains a specific value

During step 3 (after the preprocessing steps) what happens to the C source code?

The compiler translates the C modified source code into object code and stores it on the disk

During stage 2, preprocessing, who gives the command to compile the program?

The programmer

Consider the following code: int x=5, y=10; swap (x,y); void swap (int a, int b) { int temp = a; a = b; b = temp; } T/F: This function swap the values of x and y?

This function will swap a and b (parameters), but not x and y (the arguments).

How many sizes does a floating point data type comes in?

Three

T/F: pointers read right to left

True

T/F: yptr = &y; assigns the address of the variable y to pointer variable

True

T/F: A char can also be interpreted as a small integer

True

T/F: A variable name directly references a value, and a pointer indirectly references a value

True

T/F: ANSI C standard , an identifier can be of any length

True

T/F: An identifier cannot duplicate a reserved word

True

T/F: Before C-11, you can use the constant NULL to initialized the pointer to 0

True

T/F: C is case sensitive

True

T/F: Double precision double and long double precision long double has 8 bytes

True

T/F: Literal values does not change

True

T/F: Literals are not associated with a named location in memory

True

T/F: Short int has 2 bytes

True

T/F: Single precision float has 4 bytes

True

T/F: Strings in C are represented as arrays of characters terminated by a null (\0)

True

T/F: The address operator (&) is a unary operator that returns the address of its operand

True

T/F: The first character of an identifier must not be a digt

True

T/F: There is no string class in C

True

T/F: Unsigned integers stores twice as large as the signed integer of the same type (and size)

True

T/F: Use of leading underscores is discouraged for general use

True

T/F: int (16 bit) has 2 bytes

True

T/F: int (32 bit) has 4 bytes

True

T/F: int *c, b; "c is a pointer to int" or "c points to an object of type int"

True

T/F: int numOfStudents is an example of a variable declaration

True

T/F: Given: int *c,b; The ' * ' only applies to c in this definition. The variable b is still just a plain integer

True

T/F: int *c, b; specifies that variable c is of type int* (a pointer to an integer)

True

T/F: int *countptr, count; is an example of a defining a pointer

True

T/F: printf("%d", *yptr) prints the value of variable y and it is called dereferencing a pointer

True

T/F: #include <stdio.h> #define <identifier> <replacement text> are examples of preprocessor directives

True

T/F: Before the program can be executed, the program must first be placed in memory

True

T/F: Character literals are enclosed in single quotes

True

T/F: Compiler will only look at the first 31 characters of an identifier

True

T/F: During linking, multiple object files might be combined into one executable

True

T/F: In a C system, the preprocessor executes automatically before the compiler's transition phase begins

True

T/F: Pointers can be defined to point to objects of any type

True

T/F: Variables can be declared and initialized in the same statement

True

T/F: long int has 4 bytes

True

T/F: There are no boolean data type in C

True, Boolean evaluation are done through integers (0 = false and non-zero value = true)

T/F: In the previous ANSI C standard, all variable declarations in a function must be initiated before any executable statements

True, but this was changed by C99

What do you use to define a pointer?

Using an asterisk before the variable name.

How do you declare a single byte in C?

Using char (data type) keyword

What are constants?

Values that cannot be changed during the execution of a program

What are the four standard data types in C?

Void, characters, integers, and floating point data types

How many significant figures can a double precision double store?

about 14 - 15

What are the three sizes of a floating point data type?

float, double, long double

How do you define a pointer?

int * ptr;

What produces the executable code?

linker

What places the program in memory?

Loader

What is a variable?

Named locations in memory that contain a value

What does a void return?

Nothing

What are floating point literals?

Numbers with decimal values

What are integer literals?

Numbers without decimal values

What is an object code?

Object code is essentially a machine code, a binary file that consists of a series of 1's and 0's?

How many bytes is a char?

One byte

What does a pointer enable a program to do?

Pass functions between functions, and to create and manipulate dynamic data structure

What are pointers?

Pointers are variables whose values are memory addresses

What produces the modified source code?

Preprocessor

What kind of "special commands" does the C preprocessor obey?

Preprocessor directives

What does indirection mean?

Referencing a value through a pointer

What does a char usually represent?

Represents a value from the ASCII table

How can the "holes" be resolved in a C program?

Resolved by the linker

Where is the program stored?

Secondary storage device such as a hard disk

What produces the source code of a C program?

Source code is entered with a text editor by the programmer

What does C provide to return the size of any data type in bytes?

sizeof( )


Related study sets

Rosetta Stone Arabic Unit 1 Lesson 1

View Set

Chapter 67: Management of Patients with Cerebrovascular Disorders

View Set

Intermediate Accounting 2 Chapter 11 Part 1

View Set

Health Psych: Culture and Health

View Set

Information Technology Project Management 9th Edition Chapter 4

View Set

Chapter 5: Cell Division ASSIGNMENT

View Set

Chapter 12: Monopolistic Competition and Advertising

View Set