Faculty Supervisor: Al Day
Some material is derived from a lesson
by:Prof. Martha Selby
HTML Documentation by: Michelle Roberts
Last updated: 9/16/95
double n, load, (etc);
char initial, first, (etc);
An Example
What are the final values of x, y, and z?
Any number of variables may be used, by adding extra conversion
specifications in the midst of the text. Additional variables are
separated by commas.
The \n character is the symbol that is used in C to signify a return,
or newline. When this character is encountered in the midst of a
string, the computer outputs a return and then continues printing out
the rest of the characters. If no \n characters are ever used,
output will continue on one line until the edge of the screen is reached
and wrap-around occurs.
Any C variable can be made integer, floating, or character using a
declaration statement as follows:
TYPE DECLARATION STATEMENTS![]()
int a, delta, (etc);
In C, characters are represented by single quotes ('). This is to
distinguish characters in C programs fom variables. Keep this in mind
if you assign character values to character variables.
EXAMPLES OF C EXPRESSIONS![]()
Example:
ARITHMETIC ASSIGNMENT STATEMENT![]()
y=a*b*b;
Upon encountering this statement, the computer evaluates the C
expression, assigns the value to the variable and then stores y in a
predefined location on the computer stack.
The equal sign (=) should be called the assignment operator.
ASSIGNMENT SHORTCUTS![]()
You can also combine type declarations and assignment statements.
e.g. int x = 5 ;
-=, *=, /= may also be used for
subtraction, multiplication, and division respectively.
int x, y, z ;
x = 10 ;
x += 5 ;
y = x++ ;
z = ++y - x++ ;
x is 17 (10+5+1+1)
EASY? Well, not exactly.
y is 16 (15+1)
z is 0 (16-16)
The standard form for I/O is:
DEFAULT INPUT/OUTPUT![]()
function("text%_", variable);
The underscore corresponds to a conversion specification for the type of
variable being scanned or printed.
e.g. function("text%_text%_", var1, var2);
When scanning input into a variable, the variable name must be preceded
by an &.
e.g. scanf("%_", &invar);
INPUT EXAMPLE![]()
printf("Enter Velocity.");
scanf("%lf", &vel);

#include < stdio.h> /* standard header file for I/O */
SEPARATED WITH COMMAS![]()
int
main (void)
{
double points; /*declare points to be type double */
}
int sn,ng; /* declare sn & ng to be integers */
printf("Enter student number, total points, number");
printf(" of grades\n"; /* print a prompt message */
scanf("%d%lf%d", &sn, &points, &ng);
return (0);