Study Guides for midterm 1 Chapter 2 a)What is an identifier? Be able to tell if an identifier is valid or not?

An identifier is a word used to name a memory location that holds data, program results and name operations that are defined by a programmer or user. An identifier is only valid if it: 1. starts with a letter 2. consists of letters, numbers and underscores 3. is not a reserved word b) What is a reserved word in C? A reserve word is an identifier that has special meaning in C and cannot be used for different purposes. Reserve words are often identifiers from standard libraries and names of memory cells. Examples are int, void, double, return c) What is a data type in C means? Different data types in C? Data types in C tell what type of data is in a variable. The different data types are Integer(int), real numbers(double) and characters(char). You can use common arithmetic operations like addition, subtraction, multiply and divide also you can compare two integers. Integers are only whole numbers no decimals are allowed. The range of int is from -32767 to 32767. You can use common arithmetic operations like addition, subtraction, multiply and divide also you can compare two doubles (real numbers). Double consist of a real numbers and can even have decimal numbers. Ex 2.14, .0056 Data type char represents an individual character value like a letter or a number. Each character must be stored in two apostrophe like so µa¶, ¶1¶, ¶3¶, µb¶. You can compare chararacters like this µ9¶> µ1¶. You can also preform math operations on them.

identify how to input them using scanf() . g) How to use the printf() function for various data types? Printf for datatype double: Printf(³Example number is %f´. e) What does it mean to initialize a variable? To initialize a variable means that you are telling the C compiler the name of a variable. f) How to use scanf() function for various data types? Scanf for datatype double: Scanf(³%lf´. Scanf for datatypeint: Scanf(³%d´. &example). int age. Scanf for datatype char: Scanf(³%c´. identify the output i) Given a set of input data. Declare a variable like so: Double temp.d) What is a variable? And how to declare variables in C? A variable is a memory cell used to store a programs input or output data. Char letters.example). &example). Printf for datatypeint: Printf(³Example for int number %d´ .example). &example). the kind of data stored in the variable and how the data is represented in memory. Printf for datatype char Printf(³Example for char types %c´ .example). h) Given a printf() statement(s) with placeholders and variable names.

14 int main() Or double pi = 3.h> #define pi 3. A globally declared variable is initialized for any function.j) What does it mean by preprocessor statements? A preprocessor statement is a statement that is used before the program is initiated. Ex. int main() m) How to indicate comments in a C program means? To indicate a comment you use /* all*/ or \ n) Arithmetic expressions using + . The variable is only initialized in the function and its value varies from function to function./ * and % + / * = = = = addition subtraction division multiplication .14 #if k) What does it mean by global declaration? And local declaration? Global declaration is when a variable is declared outside of the main function. Local declaration is when a variable is declared in a function.14. l) How to declare constants in C? To declare a constant you declare a variable outside the main function. Different types are the: #include <stdio. # define pi 3.

p) Evaluating result of mixed type expressions. data of one or more subtypes can be converted to a supertype as needed at runtime so that the program will run correctly.% 3. Ex. 1. *. Binary +. Some languages allow.5) Implicit type conversion. A statement with a syntax error cannot be translated and the program will not run.r) Writing mathematical expressions in C z . In some cases such in a forced conversion from double to int data can be lost.(a + b / 2) + w * -y s) What is syntax error? Logic error? And run time errors? Syntax errors occur when code violates one or more grammar rules of C. Unary operators -. also known as coercion.In a mixed-type expression. compilers to provide coercion. As in the case of double to int the decimal value is lost only the whole number is kept.+ example -5 or +5 2. is an automatic type conversion by the compiler./. Types of syntax errors: . or even require. How to indicate casting in C? Casting allows you to convert type of data by placing the desired type in parenthesis in front of the expression. rounded_x = (int)(x + 0.% = division but the remainder is given to the variable instead of the answer Example of arithmetic operation Example = 1*2 o) Type Conversion through casting and coercion. int and double = double int and int = int double and double =double q) Know the precedence and associativity of operators.

identify the output or identify an error or errors Chapter 3 a) What is a function? b) What are advantages of using functions? c) What is driver-stub method of problem solving? d) How to define a function prototype in C? e) How to implement a function in C? f) How to call a function? g) Given a function definition. identify result of the function call. Run-time errors are displayed by the pc when the program is run. End of a comment using /* is not closed in */ Logic errors occurs when a program follows a faulty algorithim the program runs but the output is wrong. It occurs when the program directs the pc to perform an illegal operation like dividing a number by 0. Missing semicolon at the end of a statement 2. o) Given a snippet of codes showing a function prototype. what is the function header? h) What is an argument of a function? i) What is a parameter or parameter list of a function? j) What is a void function? k) What is a value-return function? l) How to pass data to a function? m) How to pass data out from a function? n) How to access mathematical functions in C? Name at least two mathematical functions in C.1. function definition and function called. p) Write a function prototype and function definition for a simple problem. Undeclared variables 3. t) Given a snippet of code. Chapter 4 a) What is a selection control structure? b) What is a compound statement? c) What are the relational operators in C? d) How to expression a condition for testing in C? e) Comparing numerical or character values? f) What is considered true and false in C? g) What are the logical operators in C? and their precedence? h) Know how && || and !operators are evaluated .

identify the output. nested if-else or switch statements. t) Write a function definition that involves the use of selection control structure. .i) Precedence of logical operators compared to relational operators j) What is short circuit evaluation? k) What is an unary operator? l) How to write compound condition for values in a range? m) How to write compound condition for values outside a range? n) How to write if-condition in C? o) How to write if-else condition in C? p) How to write nested if-else in C? q) How to write if-else structure using switch statements? r) How does a break statement works in switch statements? s) Given a snippet of codes with some if. if-else.