Úvod do jazyka C
CS50 - Introduction
to Computer Science
https://www.edx.org/course/introduction-computer-science-harvardx-cs50x
Algorithm
a set of steps to accomplish a task
more coming soon...
printf
printf();
printf("Hello World");
int main(){
printf("Hello World");
}
#include <stdio.h>
int main(){
printf("Hello World");
}
source code
compiler
Otvor kapotu
Hoho
Vyber sviečku
Vlož novú sviečku
Zatvor kapotu
HohoHoho
OneTime
NextTime
Ktorú sviečku?
Druhú
Interpreter
Java
Otvor kapotu
Hoho
Vyber sviečku
Vlož novú sviečku
Zatvor kapotu
HohoHoho
OneTime
NextTime
Ktorú sviečku?
Compiller
C
Otvor kapotu
Hoho
Vyber druhú sviečku
Vlož novú sviečku
Zatvor kapotu
HohoHoho
OneTime
NextTime
Compiller
C
Interpreter
Compiller
-
Runs slowly
-
Starts right away
-
Let you see results
-
Program runs quickly
-
Extra preparation time
JavaScript
Python
C
Swift
Pascal
Java
Interpreter
compiler
source code
object code
01011111 10110100 10111110 10100101 11011010 10010010 11011100 01001101
10111001 10011001 01111001 01100100 01111101 01101100 11110100 10010100
11111100 11000101 01110110 11011011 00110101 10111100 11110010 00101111
00100100 10110101 10000101 10011101 11100110 11011011 01010100 10110111
00001000 01011001 10111011 10101101 00100101 01001110 11111001 10110111
11011000 00001010 01001000 11100100 01101011 00101011 01011000 10110011
11110111 00111011 01100000 10101000 01111000 10001011 01001011 00010100
11101111 00101111 10110100 10100100 11100110 11101011 01101101 00001011
01011111 10110100 10111110 10100101 11011010 10010010 11011100 01001101
10111001 10011001 01111001 01100100 01111101 01101100 11110100 10010100
11111100 11000101 01110110 11011011 00110101 10111100 11110010 00101111
00100100 10110101 10000101 10011101 11100110 11011011 01010100 10110111
00001000 01011001 10111011 10101101 00100101 01001110 11111001 10110111
11011000 00001010 01001000 11100100 01101011 00101011 01011000 10110011
11110111 00111011 01100000 10101000 01111000 10001011 01001011 00010100
11101111 00101111 10110100 10100100 11100110 11101011 01101101 00001011
How to compile a program?
gcc -o helloworld helloworld.c
make helloworld.c
or
Windows
cygwin
mingw
OSX
xcode
Linux
coffee :)
How to install compiller?
./helloworld
How to run program?
September 9, 1947,
Houston, we have a BUG!
DRY
Don't Repeat Yourself
WET
Write Every Time
Function
sequence of program instructions that perform a specific task , packaged as a unit
ret_type name(params);
void
Definition
vs
Declaration
Function Call
Sequence
What IF
if(a<0){
printf("Hello");
}
IF
if(a<0){
printf("Hello");
}
else{
printf("World");
}
IF
if(a<0){
printf("Hello");
}
else{
printf("World");
}
ELSE
while(a<0){
printf("Hello");
a++;
}
WHILE
for(int i=0; i<10; i++){
printf("Hello %d", i);
}
FOR
Questions?
Úvod do jazyka C
By tomaslorinc
Úvod do jazyka C
- 422