C Primer Plus 第6版 第二章 编程练习参考答案

编译环境VS Code+WSL GCC

/*第一题*************************/
 #include<stdio.h>
int main()
{
    printf("Xiao Yang");
    printf("Xiao\nYang\n");
    printf("Xiao ");printf("Yang");
    getchar();
    return 0;
    
}
/*第二题 *************************/ 
 #include<stdio.h>
int main()
{
    printf("I'm XiaoYang\n");
    printf("I form Zhejiang Jiaxing\n");
    getchar();
    return 0;
} 
/*第三题 *************************/ 
 #include<stdio.h>
int main()
{
    int age,days;
    printf("Please input your age:\n");
    scanf("%d",&age);
    days = age *365;
    printf("%d years is %d days!\n",age,days);

    getchar();
    return 0;
} 
/*第四题 *************************/ 
 #include<stdio.h>

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

void jolly()
{
    printf("For he's a jolly good fwllow!\n");
}

void deny()
{
    printf("Which nobody can deny!\n");
} 
 /*第五题 *************************/  
 #include<stdio.h>

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

void jolly()
{
    printf("For he's a jolly good fwllow!\n");
}

void deny()
{
    printf("Which nobody can deny!\n");
} 
  /*第六题 *************************/  
 #include<stdio.h>
int main()
{
    int toes = 10;
    printf("toes : %d\n",toes);
    printf("toes*2 : %d\n",toes * 2);
    printf("toes*toes : %d\n",toes * toes);
    getchar();
    return 0;
} 
  /*第七题 *************************/  
 #include<stdio.h>
void smile()
{
    printf("Smile!");
}
int main()
{
    smile();smile();smile();printf("\n");
    smile();smile();printf("\n");
    smile();printf("\n");
    
    getchar();

    return 0;
} 
  /*第八题 *************************/  
 #include<stdio.h>
void two()
{
    printf("two\n");
}
void one_three()
{
    printf("one\n");
    two();
    printf("three\n");
}
int main()
{
    printf("starting now:\n");
    one_three();
    printf("done!");
    getchar();
    return 0;
} null
posted @ 2022-07-16 20:35  PYPYN  阅读(54)  评论(0编辑  收藏  举报