– Source code: The stuff you type into the computer.
– Compile (build): Taking source code and making a
program that the computer can understand.
– Executable: The compiled program that the computer
– Language: (Special sense) The core part of C central
– Library: Added functions for C programming which
– Header file: Files ending in .h which are included at
beginning (START) or the end (END) of a task.
Used for input and output operations, such as reading and
displaying. The data to be read or displayed are described inside.
Used for arithmetic and data-manipulation operations. The
instructions are listed inside the symbol.
Used for any logic or comparison operations. The decision symbol has one entry and two exit paths.
The path chosen depends on whether the answer to a question is YES or NO.
Used to indicate that the flowchart continues to the next
Used to represent a group of statements that perform one
void main() {printf( “Welcome to C!\n" );
• Every program you’ll write for this class will “include” the
standard functions in “stdio.h”.
• Functions like printf (which is in stdio.h) aren’t part of the
core C language, so you need to include them explicitly.
• All C programs must have a main() function; this is the
first function invoked. The program terminates when this function terminates.
• void indicates that the program itself returns no
value. Don’t worry about this too much now.
• But: note that some compilers insist on the
statement return 0; should be added to end of program, or anywhere else where you want the program to end. (Returning “0” indicates that the program ended successfully.)
Escape sequence Description
Newline. Position the cursor at the beginning of the next line.
Horizontal tab. Move the cursor to the next tab stop.
Backslash. Insert a backslash character in a string.
Double quote. Insert a double-quote character in a string.
• To define a variable is to request storage (memory)
for a particular data type. A variable is just a named area of storage that can hold a single value (numeric or character).
• There are two types of variables :
o local variables - variables that are used within the current
o global variables - variables that are available to all the
• A sequence of operands & operators that reduces to
There are five basic data types associated with variables: • int - integer: a whole number. An int variable can store a
value in the range -32768 to +32767 and normally associated with a decimal number.
• float - floating point value: ie a number with a fractional part.
A float, or floating point, number has about 7 digits of precision and a range of about 1.E-36 to 1.E+36. A float takes four bytes to store.
• double - a double-precision floating point value. A double, or
double precision, number has about 13 digits of precision and a range of about 1.E-303 to 1.E+303. A double takes eight bytes to store.
• char - a single character. A single character stored in one
• void - valueless special purpose type.
• We must declare the type of every variable we
• Every variable has a type (e.g. int) and a
• This prevents some bugs caused by spelling
errors (misspelling variable names).
• Declarations of types should always be together
at the top of main or a function (see later).
• Other types are char, signed, unsigned,
int x, y;int sum;printf( "Enter an integer: " );scanf( "%d", &x );printf( "Enter another integer: " );scanf( "%d", &y );sum = x + y;printf( "%d plus %d is %d\n", x, y, sum );
An identifier that can consists of letters, digits,
General form for definitions of variables:
datatype variable1, variable2,……, variable n;
• Variables in C can be given any name made from
numbers, letters and underlines which is not a keyword and does not begin with a number.
• A good name for your variables is important
• Ideally, a comment with each variable name helps
• In coursework I like to see well chosen variable names
and comments on variables (I don’t always do this in notes because there is little space). General form for scanf:
scanf (“%conversion”, &variable);
• scanf is like printf, except it reads from
standard input instead of writing to it.
• &x is a reference to the variable x rather
than the value of x itself. You need to pass a reference so that scanf can modify the variable x.
printf co nversion scanf con version Data type specification specificatio n
printf(“Sum is %d\n”,integer1+integer2);
– Use * for multiplication and / for division– Integer division truncates remainder
– Modulus operator(%) returns the remainder
• Operator precedence – similar to mathematics rules
– multiplication before addition– use parenthesis when needed– Eg. Find the average of three variables a, b and c
• Do not use: a + b + c / 3• Use: (a + b + c ) / 3
Arithmetic Algebraic C opetration C expression operator expression Operator(s) Operation(s) Order of evaluation (precedence)
Evaluated first. If the parentheses are nested, the expression in the innermost pair is evaluated first. If there are several pairs of parentheses “on the same level” (i.e., not nested), they are evaluated left to right.
Evaluated second. If there are several, they are
Evaluated last. If there are several, they are
• Assignment operators abbreviate assignment expressions
can be abbreviated as c += 3; using the addition assignment
• Examples of other assignment operators:
d -= 4 (d = d - 4)e *= 5 (e = e * 5)f /= 3 (f = f / 3)g %= 9 (g = g % 9)
Assignment Sample Explanation Assigns operator expression
Texto de la Ficha Técnica común a todas las especialidades farmacéuticas que contienen Cerivastatina RESUMEN DE CARACTERÍSTICAS DEL PRODUCTO MARCAS/TITULAR DE LAS ESPECIALIDADES Laboratorio titular COMPOSICIÓN CUALITATIVA Y CUANTITATIVA + FORMA FARMACÉUTICA • 1 comprimido de cerivastatina 0,1 mg contiene 95,4 microgramos (mcg) de cerivastatina (DCI); equival
Merllori Institute is dedicated to improving the efficacy of sustainable, eco-friendly food and biomass product production. Transitioning agriculture products and practices from laboratories and small plots to mid-size industrial production under real world market conditions is a particular focus. Prologue Seventy years elapsed between Merllori Institute’s genesis an