Top Banner
CSCI 1730 March 27 th , 2012
12

CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

Dec 24, 2015

Download

Documents

Lindsay Hunter
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

CSCI 1730March 27th, 2012

Page 2: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

TextSystem Programming with C and Unix by

Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings Ch 4: Pointers and Structures

Ch 5: Input/OutputCh 6: Program Management

Ch 7: System CallsCh 8: Libraries Ch 9: Scripting Languages

Page 3: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

HW: Read chapters 1 and 2

Page 4: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

Common shell commandscdpwdset which

Page 5: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

Common system commandsgreplsmanmoretimesort

Page 6: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

Read sections in Ch. 1:Text editors & how to use (we’ve covered

this)How to debug

try out the sample programs providesProgram development

Page 7: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.
Page 8: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

C review – 4 data types

/* A review of the basic data types in C. (pg 36) */

#include <stdio.h>

int main(){int x,y;char a;float f,e;double d;

x=4;y=7;a='H';f=-3.4;d=54.123456789;e=54.123456789;

printf("%d %c %f %lf\n",x,a,e,d);printf("%d %c %.9f %.9lf\n",x,a,e,d);}

Page 9: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

C review – arithmetic

/* A review of the basic arithmetic operators in C. (pg 37) */

#include <stdio.h>

int main(){int x,y;int r1,r2,r3,r4,r5;

x=4;y=7;r1=x+y;r2=x-y;r3=x/y;r4=x*y;printf("%d %d %d %d\n",r1,r2,r3,r4);

r3++;r4--;r5=r4%r1;printf("%d %d %d\n",r3,r4,r5);}

Page 10: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

C review – loops#include <stdio.h>

/* A review of the loop types in C. (pg 38) */int main(){int i,x;

x=0;for (i=0; i<4; i++) { x=x+i; printf("%d\n",x); }while (i<7) { x=x+i; i++; printf("%d\n",x); }do { x=x+i; i++; printf("%d\n",x); }while (i<9);}

Page 11: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

C review – blocks

/* A review of conditionals and blocks in C. (pg 39) */

#include <stdio.h>

int main(){int i,x;

x=0;for (i=0; i<5; i++) { if (i%2 == 0 || i == 1) x=x+i; else x=x-i; printf("%d\n",x); }}

Page 12: CSCI 1730 March 27 th, 2012. Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.

C review – flow control

/* A review of flow control statements in C. (pg 40) */

#include <stdio.h>

int main(){int i,x;

x=0;for (i=0; i<5; i++) { if (i%2 == 0) continue; x=x-i; if (i%4 == 0) break; printf("%d\n",x); }}