week1m

43
This is CS50.

Upload: tauqeer729

Post on 20-May-2015

183 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Week1m

This is CS50.

Page 2: Week1m

scribe notes

Page 3: Week1m

problem set 0

Page 4: Week1m

walkthroughcs50.net/psets

Page 5: Week1m

sectioningcs50.net/section

Page 6: Week1m

office hourscs50.net/ohs

Page 7: Week1m
Page 8: Week1m
Page 9: Week1m
Page 10: Week1m

int  main(void){        printf("hello,  world!\n");        return  0;}

Page 11: Week1m

statements

Page 12: Week1m

statements

printf("hello,  world!\n");

Page 13: Week1m

loops

Page 14: Week1m

loops

while  (true){        printf("hello,  world!\n");}

Page 15: Week1m

loops

Page 16: Week1m

loops

for  (int  i  =  0;  i  <  10;  i++){        printf("hello,  world!\n");}

Page 17: Week1m

variables

Page 18: Week1m

variables

int  counter  =  0;while  (true){        printf("%d\n",  counter);        counter++;}

Page 19: Week1m

Boolean expressions

Page 20: Week1m

Boolean expressions

(x  <  y)((x  <  y)  &&  (y  <  z))

Page 21: Week1m

conditions

if  (x  <  y){        printf("x  is  less  than  y\n");}else  if  (x  >  y){        printf("x  is  greater  than  y\n");  }else{        printf("x  is  equal  to  y\n");}

Page 22: Week1m

arrays

string  inventory[1];inventory[0]  =  "Orange";

Page 23: Week1m

#include  <stdio.h>

int  main(void){        printf("hello,  world!");        return  0;}

Page 24: Week1m

10000011 00000001 00010001 00000000 00111101 11111100 01110100 0011110100000000 01000000 00000000 00000000 00000000 00000000 00000000 0000000010010000 00000000 00000000 00000000 01010000 00000000 00000111 0011000000001011 00000001 00001011 00000011 00001010 00000000 00000000 0000000000000000 00100000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00100000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000001110000 00010000 00000000 00100000 00000001 00000000 00000000 0000000000000000 00000000 00000000 00100000 00000001 00000000 00000000 0000000000000000 00000000 00000000 01000000 00000001 00000000 00000000 0000000000000000 00100000 00000000 01000000 00000001 00000000 00000000 0000000011111111 11111111 11111111 11111111 11111111 11111111 11111111 1111111110010000 10000000 00000000 01000000 00000001 00000000 00000000 0000000000101110 01100100 01111001 01101110 01100001 01101101 01101001 0110001110110000 00000100 00000000 00100000 00000001 00000000 00000000 0000000010110000 00000100 00000000 00100000 00000001 00000000 00000000 0000000010100000 00000001 00000000 00000000 00000000 00000000 00000000 0000000010110000 00000100 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00100000 00000000 00000000

...

Page 25: Week1m
Page 26: Week1m

how to write a program

Page 27: Week1m

how to compile a programclang  hello.c

Page 28: Week1m

how to run a program./a.out

Page 29: Week1m

how to compile a programclang  -­‐o  hello  hello.c

Page 30: Week1m

how to run a program./hello

Page 31: Week1m

how to compile a programmake  hello

Page 32: Week1m

functionsmain

Page 33: Week1m

Standard Librarystdio.h

printf

...

Page 34: Week1m

CS50 Librarycs50.h

GetChar

GetDouble

GetFloat

GetInt

GetLongLong

GetString

Page 35: Week1m

printf%c      %d      %f      %lld      %s      ...

Page 36: Week1m

escape sequences\n      \r      \t      \'      \"      \\      \0      ...

Page 37: Week1m

math+      -­‐      *      /      %

Page 38: Week1m

primitive typeschar      double      float      int      long  long      ...

Page 39: Week1m

CS50 typesbool      string      ...

Page 40: Week1m

http://www.difranco.net/cop2220/op-prec.htm

precedence

Page 41: Week1m

how to compile a programclang  -­‐o  hello  hello.c  -­‐lcs50

Page 42: Week1m

how to compile a programmake  hello

Page 43: Week1m

to be continued...