Академический Документы
Профессиональный Документы
Культура Документы
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.
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).
int main()
Or
double pi = 3.14;
int main()
+ = addition
- = subtraction
/ = division
* = multiplication
% = division but the remainder is given to the variable instead
of the answer
Example of arithmetic operation
Example = 1*2
Implicit type conversion, also known as coercion, is an automatic type conversion by the
compiler. Some languages allow, or even require, compilers to provide coercion. In a mixed-type
expression, data of one or more subtypes can be converted to a supertype as needed at runtime so
that the program will run correctly. In some cases such in a forced conversion from double to int
data can be lost. As in the case of double to int the decimal value is lost only the whole number is
kept.
z - (a + b / 2) + w * -y
Syntax errors occur when code violates one or more grammar rules
of C. A statement with a syntax error cannot be translated and the
program will not run.
Types of syntax errors:
1. Missing semicolon at the end of a statement
2. Undeclared variables
3. End of a comment using /* is not closed in */
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, 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.
o) Given a snippet of codes showing a function prototype, function
definition and function called, identify result of the function call.
p) Write a function prototype and function definition for a simple
problem.
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
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, nested if-else or
switch statements, identify the output.
t) Write a function definition that involves the use of selection
control structure.