Lecture 3: April 7, 2023
Reading
:
zyBooks text
, §2.20; [2]
Outline
Greetings and felicitations!
ssh Tutorial is now up;
Use your CAS (Kerberos) name to log in
ssh
CAS-login-name
@pc
nn
.cs.ucdavis.edu
Important
: If you do not use your CAS login, you will not log in!
To see which CSIF systems are up and which are down, go to
http://iceman.cs.ucdavis.edu/nagios3/cgi-bin/status.cgi?hostgroup=all
Example: making change [
fahr1.c
]
Add input using
scanf
Add error checking
Variable names
Basic types
int
,
long
vs.
short
,
unsigned
vs.
signed
char
, treated like an
int
that holds 1 character
float
,
double
Type casting
Basic operators
arithmetic:
+
,
-
,
*
,
/
,
%
%
defined so that
n % p = r
implies
n
=
ap
+
r
for some
a
5 % −2
can be 1 (5= (−2) × (−2) + 1) or −1 (5 = (−3) × (−2) + (−1))
Associativity of operations
Difference between associativity of operations and order of evaluation
A more sophisticated Fahrenheit to Celsius temperature converter [
fahr2.c
]
#include <stdio.h>
Macros
float
for
loop
Debugging: find the error! [
fahr2-buggy.c
]
Handouts
vim
Tutorial
vim.pdf
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email:
mabishop@ucdavis.edu
ECS 36A, Programming & Problem Solving
Version of April 6, 2023 at 3:44PM
You can also obtain a PDF version of this.