C primer plus (第六版)第二章的答案

C primer plus(第六版)第二章答案

2.1

#include 

int main(void) {
	printf("Gustav Mahler\n"); 
	printf("Gustav\nMahler\n"); 
	printf("Gustav "); 
	printf("Mahler"); 
    
	return 0;
}

2.2

#include 

int main(void) {
	printf("name: joey\n"); 
	printf("address: beijing"); 
	return 0;
}

2.3

#include 

int main(void) {
	int age2day=365*18; 
	printf(" %d days",age2day); 

	return 0;
}

2.4

#include 
void jolly(void); 
void deny(void); 
int main(void) {
	jolly();
	deny(); 
	return 0;
}

void jolly(void){
	printf("For he's a jolly good fellow!\nFor he's a jolly good fellow!\nFor he's a jolly good fellow!\n"); 
} 
void deny(void){
	printf("Which nobody can deny!"); 
}

2.5

#include 
void br(void); 
void ic(void); 
int main(void) {
	br();
	printf(", "); 
	ic(); 
    printf("\n"); 
    ic();
    printf(",\n"); 
    br();
}

void br(void){
	printf("Brazil, Russia"); 
} 
void ic(void){
	printf("India, China"); 
}

2.6

#include 

int main(void) {
	int toes = 10 ;
	int double_toes=2*toes;
	int square_toes= toes*toes;
	 printf("toes:%d ; double_toes:%d ; square_toes:%d ;",toes,double_toes,square_toes); 
}

2.7

#include 
void smile(void); 
int main(void) {
	smile(); smile();smile();
	printf("\n");
	smile();smile();
	printf("\n");
	smile();
}
void smile(void){
    printf("Smile!");	
}

2.8

#include 
void one_three(void);
void two(void);
int main(void) {
	printf("starting now:\n");
	one_three();
	printf("done!");
        return 0;
}
void one_three(void){
   	printf("one\n");
   	two();
   	printf("three\n");
}
void two(void){
   	printf("two\n");
}

你可能感兴趣的:(C)