Chapter two
1.
//打印姓名 #include<stdio.h> int main() { printf("Gustav Mahler\n"); printf("Gustav\n"); printf("Mahler\n"); printf("Gustav Mahler\n"); return 0; }
2.
// print the name and address #include <stdio.h> int main () { the printf ( " Jack Ma \ n- " ); the printf ( " CHINA \ n- " ); return 0 ; }
3.
//输入年龄返回天数 #include<stdio.h> int main() { int i_age,i_days; printf("please type you age:\n"); scanf("%d",&i_age); i_days = 365 * i_age; printf("convert to days is:%d",i_days); return 0; }
4.
//调用函数进行打印 #include<stdio.h> void jolly() { int i; for(i=0;i<3;i++) printf("For he is a jolly good fellow!\n"); } void deny() { printf("Which nobody can deny!"); } int main() { jolly(); deny(); }
5. ( contents of two sub-functions are not displayed, Resolved ) [call functions malformed, do not need to add in front of void]
#include<stdio.h> void br() { printf("Brazil,Russia\n"); } void ic() { printf("India,China\n"); } int main() { printf("Brazil,Russia,India,China"); void br(); void ic(); }
6 ( to be investigation using pow (toes, 2) calculating the square 10, the output is 99; if the direct pow (10,2) normal, direct toes * toes are normal )
#include<stdio.h> #include<math.h> int main() { int toes = 10; int i_twice,i_square; i_twice = toes * 2; i_square = pow(toes,2); printf("The twice of toes is:%d\n",i_twice); printf("The square of toes is:%d\n",i_square); return 0; }
7.
#include<stdio.h> void joker() { printf("Smile!"); } //换行 void nn() { printf("\n"); } int main() { joker();joker();joker();nn(); joker();joker();nn(); joker();nn(); }
8.
#include<stdio.h> void one_three() { printf("one\n"); two(); printf("three"); } void two() { printf("two\n"); } int main() { printf("starting now:\n"); one_three(); return 0; }
third chapter
1.