-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtutorial_week1_solution.c
More file actions
53 lines (42 loc) · 1.42 KB
/
tutorial_week1_solution.c
File metadata and controls
53 lines (42 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//I am a comment
/*
I am a multi-line
comment
*/
//The code below is a preprocessing command.
//It will be executed before compilation
#include <stdio.h>
//The code below is a function, contains a list of instructions
// to be compiled and run on the CPU.
int main()
{
//below are statements, they will be executed sequentially.
printf("My name is Song Liu. \n");
printf("I am from China. \n");
printf("My student ID is sl9885. \n");
printf("My favourite food is fried chicken. \n");
printf("My Student ID %s.\n", "sl9885");
printf("My Student ID %s%d.\n", "sl", 9885);
printf("The outcome of 1/3 is %.3f\n", 1.0/3.0);
// this does not work, why?
//printf("The outcome of 1/3 is %.3f", 1/3);
printf("This is a happy face😀.\n");
printf("|\\\n");
printf("| \\\n");
printf("| \\\n");
printf("| \\\n");
printf("|____\\\n");
//the following statement returns a value from this function.
//Here, it returns "0", means all OK with your program.
//If needded, you can return a non-zero value which means something is wrong.
return 0;
}
/*
To compile, press ctrl+' to bring out the command line.
Type ine the command line gcc THIS_FILE_NAME -o EXECUTABLE_FILE_NAME
(on Windows, the file name must end with .exe)
Press enter.
To run,
Type in the command line ./EXECUTABLE_FILE_NAME
press enter.
*/