chapter 02

This commit is contained in:
wandoubaba 2023-12-02 17:53:34 +08:00
parent 850c3bbb9f
commit 9da364716b
6 changed files with 85 additions and 0 deletions

13
c02_overview/fathm_ft.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
int main(void)
{
int feet, fathoms;
fathoms = 2;
feet = 6 * fathoms;
printf("There are %d feet in %d fathoms!\n", feet, fathoms);
printf("Yes, I said %d feet!\n", 6 * fathoms);
return 0;
}

13
c02_overview/first.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
int main(void)
{
int num;
num = 1;
printf("I am a simple ");
printf("computer.\n");
printf("My favorite number is %d because it is first.\n", num);
return 0;
}

10
c02_overview/test01.c Normal file
View File

@ -0,0 +1,10 @@
#include <stdio.h>
int main(void)
{
printf("Gustav Mahler\n");
printf("Gustav\nMahler\n");
printf("Gustav ");
printf("Mahler\n");
return 0;
}

9
c02_overview/test03.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
int main(void)
{
int age = 40;
int days = age * 365;
printf("今年%d岁活了%d多天了\n", age, days);
return 0;
}

23
c02_overview/test04.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
void jolly(void);
void deny(void);
int main(void)
{
jolly();
jolly();
jolly();
deny();
return 0;
}
void jolly(void)
{
printf("For he's a jolly good fellow!\n");
}
void deny(void)
{
printf("Which nobody can deny!\n");
}

17
c02_overview/two_func.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
void butler(void);
int main(void)
{
printf("I will summon the butler function.\n");
butler();
printf("Yes. Bring me some tea and writeable DVDs.\n");
return 0;
}
void butler(void)
{
printf("You rang, sir?\n");
}