📄 03.txt
字号:
CS 1355
Intro to Programming in C
Monday 2006.9.18 (Week 2)
Lecture Notes (at http://r638-2.cs.nthu.edu.tw/C/notes/03.txt)
Introduction to C Programming (Chapter 2)
Concepts:
- comments
- function declaration
- keywords vs. identifiers
- data types
- expressions
- operators
- variables
- assignments
Comments
- the part of the program text for humans to read
- start with /*
end with */
Can be on the same line or span multiple lines
- Example
/* This program prints "hello world"
author: Pai Chou, NTHU
Date: 2006.9.18
*/
- The preprocessor will remove comments before compiling
- Comments are very important!!
explains things to the human, including yourself in the future
Example program
/* very simple program */
#include <stdio.h>
int main() {
printf("hello world\n");
return 0;
}
Function declaration
- What is a function?
* a mathematical concept:
- inputs some values, outputs some values
- examples: (math, not C program statement)
f(x) = x**2 + 2*x - 3 => this is a quadratic function
sin(), cos(), tan(), arcsin(), ... => these are trigonometry functions
- General "mapping" (癸琈)
examples: if P is a person, then you could say
height(P), weight(P), age(P), name(P), father(P), mother(P), ...
=> in English, say "height of P", "weight of P", "age of P", ...
just like f(x) is "f of x"
* a programming concept
- a piece of program code that can be "called"
(a "caller" (
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -