• No results found

#include <stdio.h> int main(void) { printf("hello, world\n"); }

N/A
N/A
Protected

Academic year: 2022

Share "#include <stdio.h> int main(void) { printf("hello, world\n"); }"

Copied!
173
0
0

Loading.... (view fulltext now)

Full text

(1)

This is CS50

(2)
(3)

#include <stdio.h>

int main(void) {

printf("hello, world\n");

}

(4)

● functions

arguments, return values

● conditionals

● Boolean expressions

● loops

● variables

● ...

(5)
(6)
(7)

correctness

(8)

design

(9)

style

(10)

#include <stdio.h>

int main(void) {

printf("hello, world\n");

}

(11)

01111111 01000101 01001100 01000110 00000010 00000001 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000010 00000000 00111110 00000000 00000001 00000000 00000000 00000000 10110000 00000101 01000000 00000000 00000000 00000000 00000000 00000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 11010000 00010011 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 01000000 00000000 00111000 00000000 00001001 00000000 01000000 00000000 00100100 00000000 00100001 00000000 00000110 00000000 00000000 00000000 00000101 00000000 00000000 00000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 01000000 00000000 01000000 00000000 00000000 00000000 00000000 00000000 01000000 00000000 01000000 00000000 00000000 00000000 00000000 00000000 11111000 00000001 00000000 00000000 00000000 00000000 00000000 00000000 11111000 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00001000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000011 00000000 00000000 00000000 00000100 00000000 00000000 00000000 00111000 00000010 00000000 00000000 00000000 00000000 00000000 00000000 ...

(12)

input → → output

(13)
(14)

source code →

(15)

source code → → machine code

(16)

source code → compiler → machine code

(17)

make hello ./hello

(18)

functions, arguments

(19)

printf("hello, world");

(20)

printf("hello, world");

(21)

printf("hello, world");

(22)

printf("hello, world");

(23)

printf("hello, world");

(24)

printf("hello, world");

(25)

functions

(26)

functions

arguments →

(27)

functions

arguments → → side effects

(28)

→ →

(29)

return values, variables

(30)
(31)

string answer = get_string( );

printf("hello, %s", answer);

(32)

string answer = get_string("What's your name? ");

printf("hello, %s", answer);

(33)

string answer = get_string("What's your name? ");

printf("hello, %s", answer);

(34)

string answer = get_string("What's your name? ");

printf("hello, %s", answer);

(35)

string answer = get_string("What's your name? ");

printf("hello, %s", answer);

(36)

functions

(37)

functions

arguments →

(38)

functions

arguments → → return value

(39)

→ →

(40)

string answer = get_string("What's your name?\n");

printf("hello, %s", answer);

(41)

printf("hello, %s", answer);

(42)

printf("hello, %s", answer);

(43)

printf("hello, %s", answer);

(44)

main

(45)

int main(void) {

}

(46)

int main(void) {

}

(47)

header files

(48)

#include <stdio.h>

int main(void) {

printf("hello, world\n");

}

(49)

#include <stdio.h>

int main(void) {

printf("hello, world\n");

}

(50)

cd cp ls mkdir mv rm rmdir ...

(51)

types

(52)

bool char double float int long string ...

(53)

get_char get_double get_float get_int get_long get_string ...

(54)

format codes

(55)

%c

%f

%i

%li

%s

(56)

%c char

%f float, double

%i int

%li long

%s string

(57)

operators

(58)

+ -

* /

%

(59)

+ addition - subtraction

* multiplication / division

% remainder

(60)

variables, syntactic sugar

(61)

int counter = 0;

(62)

int counter = 0;

(63)

int counter = 0;

(64)

int counter = 0;

(65)

counter = counter + 1;

(66)

counter = counter + 1;

(67)

counter = counter + 1;

(68)

counter += 1;

(69)

counter++;

(70)

conditions

(71)

if (x < y) {

printf("x is less than y\n");

}

(72)

if (x < y) {

printf("x is less than y\n");

}

(73)

if (x < y) {

printf("x is less than y\n");

}

(74)

if (x < y) {

printf("x is less than y\n");

} else {

printf("x is not less than y\n");

}

(75)

if (x < y) {

printf("x is less than y\n");

} else {

printf("x is not less than y\n");

}

(76)

if (x < y) {

printf("x is less than y\n");

} else {

printf("x is not less than y\n");

}

(77)

if (x < y) {

printf("x is less than y\n");

}

else if (x > y) {

printf("x is greater than y\n");

}

else if (x == y) {

printf("x is equal to y\n");

}

(78)

if (x < y) {

printf("x is less than y\n");

}

else if (x > y) {

printf("x is greater than y\n");

}

else if (x == y) {

printf("x is equal to y\n");

}

(79)

if (x < y) {

printf("x is less than y\n");

}

else if (x > y) {

printf("x is greater than y\n");

}

else if (x == y) {

printf("x is equal to y\n");

}

(80)

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");

}

(81)

loops

(82)

while (true) {

printf("meow\n");

}

(83)

while (true) {

}

(84)

while (true) {

printf("meow\n");

}

(85)
(86)

int counter = 0;

while (counter < 3) {

}

(87)

int counter = 0;

while (counter < 3) {

printf("meow\n");

}

(88)

int counter = 0;

while (counter < 3) {

printf("meow\n");

counter = counter + 1;

}

(89)

int i = 0;

while (i < 3) {

printf("meow\n");

i = i + 1;

}

(90)

int i = 0;

while (i < 3) {

printf("meow\n");

i += 1;

}

(91)

int i = 0;

while (i < 3) {

printf("meow\n");

i++;

}

(92)

int i = 0;

while (i < 3) {

printf("meow\n");

i++;

}

(93)

int i = 0;

while (i < 3) {

printf("meow\n");

i++;

}

(94)

int i = 0;

while (i < 3) {

printf("meow\n");

i++;

}

(95)

int i = 0;

while (i < 3) {

printf("meow\n");

i++;

}

(96)

int i = 0;

while (i < 3) {

printf("meow\n");

i++;

}

(97)

int i = 0;

while (i < 3) {

printf("meow\n");

i++;

}

(98)

int i = 0;

while (i < 3) {

printf("meow\n");

i++;

}

(99)

int i = 1;

while (i <= 3) {

printf("meow\n");

i++;

}

(100)

int i = 3;

while (i > 0) {

printf("meow\n");

i--;

}

(101)
(102)

for (int i = 0; i < 3; i++) {

}

(103)

for (int i = 0; i < 3; i++) {

printf("meow\n");

}

(104)

for (int i = 0; i < 3; i++) {

printf("meow\n");

}

(105)

for (int i = 0; i < 3; i++) {

printf("meow\n");

}

(106)

for (int i = 0; i < 3; i++) {

printf("meow\n");

}

(107)

for (int i = 0; i < 3; i++) {

printf("meow\n");

}

(108)

for (int i = 0; i < 3; i++) {

printf("meow\n");

}

(109)

for (int i = 0; i < 3; i++) {

printf("meow\n");

}

(110)
(111)
(112)
(113)
(114)
(115)
(116)
(117)
(118)

floating-point imprecision

(119)

integer overflow

(120)

0000

(121)

0001

(122)

0010

(123)

0011

(124)

0100

(125)

0101

(126)

0110

(127)

0111

(128)

1000

(129)

1000

(130)

1 January 2000

(131)

1999

(132)

1999

(133)

1900

(134)

19 January 2038

(135)

2147483647

(136)

01111111111111111111111111111111

(137)

01111111111111111111111111111111

1

(138)

1

01111111111111111111111111111110

(139)

1

01111111111111111111111111111100

(140)

1

01111111111111111111111111111000

(141)

01111111111111111111111111110000

(142)

01111111111111111111111111100000

(143)

01111111111111111111111111000000

(144)

01111111111111111111111110000000

(145)

01111111111111111111111100000000

(146)

01111111111111111111111000000000

(147)

01111111111111111111110000000000

(148)

01111111111111111111100000000000

(149)

01111111111111111111000000000000

(150)

01111111111111111110000000000000

(151)

01111111111111111100000000000000

(152)

01111111111111111000000000000000

(153)

01111111111111110000000000000000

(154)

01111111111111100000000000000000

(155)

01111111111111000000000000000000

(156)

01111111111110000000000000000000

(157)

01111111111100000000000000000000

(158)

01111111111000000000000000000000

(159)

01111111110000000000000000000000

(160)

01111111100000000000000000000000

(161)

01111111000000000000000000000000

(162)

01111110000000000000000000000000

(163)

01111100000000000000000000000000

(164)

01111000000000000000000000000000

(165)

01110000000000000000000000000000

(166)

01100000000000000000000000000000

(167)

01000000000000000000000000000000

(168)

10000000000000000000000000000000

(169)

-2147483648

(170)

13 December 1901

(171)
(172)
(173)

This is CS50

References

Related documents

Evaluating core principles of PRME against a framework based on Sen’s capabilities such as human well-being, pluralism and social participation, the conclusion is that PRME and its

The purpose of this study is to identify cultural factors influencing the management of HIV/AIDS patients in order to raise awareness and improve management of

Fiber Optic Wireless Airmux Airmux ETX/Megaplex/ PacketLight Fib er Op tic Fib er Op tic New PSTN/OTN Fiber Optic Megaplex Megaplex Meter Concentrator Fib er Op tic Fib er Op

[r]

59 However, Schrödinger’s wave equation is not complete as an explanation either: while it explains the gross and fine structure of a hydrogen atom, it does not explain the

The chorus includes 25 people (9 for soprano, 5 for countertenor, 5 for tenor and 6 for bass), with high tenor as the replacement of a contralto part among them. The show is

A definite sentence is said to be of finite degree if for no negative clause N there exists an SLD-tree with N as root and containing a node of infinite

aprovecharon las divisiones políticas existentes en las islas, en particular La Gomera, Gran Canaria, La Palma y Tenerife, y probablemente también en Fuerteventura, como elemento