C Primer Plus_编程练习答案
作者:互联网
第二章
1.
#include <stdio.h>
int main(void)
{
printf("Gustav Mahler\n");
printf("Gustav\nMahler\n");
printf("Gustav ");
printf("Mahler\n");
return 0;
}
2.
#include <stdio.h>
int main(void)
{
printf("My name is Gustav Mahler.\n");
printf("My hometown is China.\n");
return 0;
}
3.
#include <stdio.h>
int main()
{
int years, days;
years = 18;
days = years * 365;
printf("I am %d years old, it have over %d days.\n", years, days);
return 0;
}
4.
#include <stdio.h>
void jolly(void);
void deny(void);
int main(void)
{
jolly();
jolly();
jolly();
deny();
return 0;
}
void jolly(void)
{
printf("For he is a jolly good fellow!\n");
}
void deny(void)
{
printf("Which nobody can deny!\n");
}
5.
#include <stdio.h>
void br(void);
void ic(void);
int main(void)
{
br();
printf(", ");
ic();
printf("\n");
ic();
printf("\n");
br();
printf("\n");
return 0;
}
void br(void)
{
printf("Brazil, Russia");
}
void ic(void)
{
printf("India, China");
}
6
#include <stdio.h>
int main(void)
{
int toes = 10;
printf("toes is %d.\nDoule toes is %d\nsquater toes is %d\n", toes, 2 * toes, toes*toes);
return 0;
}
7.
#include <stdio.h>
void sl(void)
int main(void)
{
sl();
sl();
sl();
printf("\n");
sl();
sl();
printf("\n");
sl();
printf("\n");
return 0;
}
void sl(void)
{
printf("Smile!");
}
7.
#include <stdio.h>
void one_three(void);
void two(void);
int main()
{
printf("starting now:\n");
one_three();
printf("done!\n");
return 0;
}
void one_three(void)
{
printf("one\n");
two();
printf("three\n");
}
void two(void)
{
printf("two\n");
}
标签:main,toes,return,int,void,编程,Plus,printf,Primer 来源: https://blog.csdn.net/LeLecode_com/article/details/114993329