Programming in C

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Explain how loops work

- Given a condition, a loop will execute a certain block of code - After execution has completed, the condition is re-evaluated; if the condition is no longer true, the loop exits; if the condition is true, the loop continues to execute

Describe the shorthand notation for incrementing/decrementing in C

- Increment: variableName++; - Decrement: variableName--;

Describe use of preprocessing directives

- Tell the compiler to do something before compilation. - Ex: #include <filename.h>, tells the compiler to include the code located in "filename.h" during compilation

Describe character type variables

- The least amount of memory of all variable types - Used to store singular ASCII character's - Signed or Unsigned

Identify purpose of index values in an array

- Used to access a specific element of an array. - Ex: myArray[0]; will access the first element of the array "myArray"

Identify the purpose of the "switch" statement

- Used to execute a certain block of code if a variable equals a certain value - Best used if all choices are known (ie a menu system) - Has a default case that executes if the variable does not equal any of the cases given

Identify the purpose of the {} braces in an if statement

- Used to identify the code that should be executed if the "if" statement is evaluated as true

Explain the relationship between variables and memory

- When a variable is declared the computer allocates a space in memory big enough to store it - Variables of the same "type" will occupy the same amount of memory

Explain the use of the "if-else" statement

- either/or situation - If the condition stated in the "if" statement is not true, then the code within the "else" {} block of execution code is executed

Identify syntax for implicit type conversion

- numberOne/(float)numberTwo - This will automatically convert numberOne as well

Explain the use of a basic "if" statement

- used to evaluate a condition - If the condition is true, code within the {} block of execution code is executed

Explain scope as it relates to variables

- variables created with a {} block will only "live" for the duration of that block of code - If that function, or block of code is executed again at another point in time; that variable is re-created (it is NOT the same variable or value as before)

Know what a compiler does

-Performs the "compiling" step of creating a program in C. -Creates an object file (source code turned into instructions understandable by a machine) -Invoked via command line -Can have multiple objects linked during the "linking phase" -Can detect syntax errors

Identify the four fundemental stages of creating a program in C

1. Editing 2. Compiling 3. Linking 4. Executing

Identify the fundamental relational operators

== < > <= >= !=

Define arrays

A fixed number of data items that are all of the SAME data type (Ex: int, float, char)

Know what a linker does

Take all of the object files created by the compiler, and links them together into one executable file.

Identify the compiler's role in handling coding errors

The compiler will detect syntax errors and quit compilation of the source code. The program author must correct the error through editing and re-compile the program

Define Executing

The process of "running" the file created by the linker. All previous steps must have been completed successfully

Define Editing

The process of creating or modifying code

Identify pointer instantiation

int *myIntPointer - Use the "*" before the variable name - If you output myIntPointer you will get the address of where the data is stored - If you output *myIntPointer it will out put the actual data

Explain how to create a multi-dimensional array

int myArray[5][3]; This will create a 5x3 array

Five basic arithmetic operators (C)

+ - * / %

Identify syntax for explicit type conversion

- (float)numberOne/(float)numberTwo

Define Functions

- A named block of code. Code between {} braces executes then returns control of the program back to the parent function upon completion. - Used to break a program up into segments - Each C program requires one or more functions

Define variables

- A specific piece of memory in your computer that consists of one or more contiguous bytes - Not fixed, may change as needed

Explain the purpose of the "main()" function

- All C programs require the main() function. - main() is the starting point of all C programs

Define string constants

- An array of "char"'s terminated by a null character (\0) - A sequence of characters or symbols between a pair od double-quote characters

Identify the use of comments in C

- Documentation of code inside the source file. - Assists in code maintenance - Can also comment out code for troubleshooting purposes

Explain how functions operate when called

- Functions are called by using their name: Ex: squareMyNumber(2) - They will execute code within their {} block and return the value calculated by the function - functions need a declaration at the top of the file, a place where they are called, and the definition of the function that contains the actual code to execute

Identify the purpose of function parameters

Pass data to a function so it may use that data during execution

Outline variable scope as it relates to functions

Functions cannot read or write to variables created outside of their scope (unless that variable was passed to the function as a parameter)

Describe floating point variables

Holds values that are written with a decimal point

Identify the purpose of the nested loop

Use when you need a loop inside of another loop. (ie do one task multiple times for each iteration of the main loop)

Explain how to hold a string in C

char myString[5]="My C"; myString[0]="M" myString[1]="y" myString[2]=" " myString[3]="C myString[4]="\0"

Explain how pointers differ from other variable types

pointers do not store the value of the variable, they store the address that does hold the data

Identify the keyword that returns control to the calling function

return

Identify the header file required to use common string functions

string.c

Recognize the different integer variable types

unsigned char unsigned shor int unsigned int unsigned long int unsigned long long int signed char signed shor int signed int signed long int signed long long int

Interpret the syntax of the while loop

while(condition) { CODE TO EXECUTE } --------------------------- If the "condition" is true, CODE TO EXECUTE, will execute. Condition is re-evaluated at each iteration of the loop

Describe integer variables

whole numbers (numbers WITHOUT a decimal point)


Set pelajaran terkait

NURS 111 Exam 3 Thyroid PrepU questions

View Set

Sukys Business Law 15th Edition Ch. 1-3

View Set

The Ovaries and Fallopian Tubes - Chapter 18 (Review Questions)

View Set

Exam 3 Study Questions 345 Sexuality Quiz

View Set

MC Test for Unit 3 APUSH PART 1!!

View Set

MICROBIO 310 Exam 1 Sample Questions

View Set

Personal Finance Quiz 1 Study Guide True+False Section

View Set