zoukankan      html  css  js  c++  java
  • C Primer Plus_第二章_C语言概述_复习题与编程练习

    REVIEW

    1.如何称呼C程序的基本模块?
    ans
    它们被称为函数

    2.什么是语法错误?给出一个英语例子和一个C语言例子
    me
    C的语法错误是指把正确的C符号放在了错误的位置
    likes coding He. 
    int main(void)
    ()
    ans
    语法错误就是指违背了如何把语句或程序放置在一起的规则。
    Me speaks English good.
    printf "where are the parentheses?";

    3.什么是语义错误?给出一个英语例子和一个C语言例子
    ans
    语义错误就是指含义上的错误(编译不出语法错误)。
    My favorite singer is GuoDegang.
    thrice_n = 3 + n;

    4.评定下面的程序
    #include <</font>studio.h>
    int main(void)  
    ({
    int s;

    s: = 56;s= 56;
    printf ("There are s%d weeks in a year.",s);
    return 0;
    )}



    PRACTICE
    1.利用printf函数输出姓名
    #include
    int main(void)
    {
    printf("Tom Smith ");
    printf("Tom Smith ");
    printf("Tom ");
    printf("Smith ");
     
    return 0;
    }
     
    2.输出您的姓名和地址

    #include
    int main(void)
    {
     printf("Name: Tom Smith ");
     printf("Add: China AnHui MaAnShan ");
     return 0;
    }
     
    3.把年龄转换成天数并显示二者的值

    #include
    int main(void)
    {
     int age;
     int day;
     age = 24;
     printf("tom is %d years old ",age);
     printf("tom has been on earth for %d days ",age*365);
     return 0;
    }
     
    4.

    #include
    void prnt1(void);
    void prnt2(void);
    int main(void)   //主函数定义用 int main(void)
    {
     prnt1();
     prnt1();
     prnt1();
     prnt2();
     return 0;
    }
    void prnt1(void)  //子函数定义用 void func(void)
    {
     printf("For Tom is a jolly good fellow! ");
    }
    void prnt2(void)
    {
     printf("Which nobody can deny!!! ");
    }
     
    5.

    #include
    int main(void)
    {
     int toes,t_sqr,t_sum;
     toes = 10;
     t_sqr = toes * toes;
     t_sum = toes + toes;
     printf("toes = %d toes and = %d toes square = %d ",toes,t_sum,t_sqr);
     
     return 0;
    }
     
    6.

    #include
    void prt_s(void);
    void prt_n(void);
    int main(void)
    {
     prt_s();
     prt_s();
     prt_s();
     prt_n();
     prt_s();
     prt_s();
     prt_n();
     prt_s();
     prt_n();
     return 0;
    }
    void prt_s(void)
    {
     printf("Smile!");
    }
    void prt_n(void)
    {
     printf(" ");
    }
     
    7.

    #include
    void one_three(void);
    void two(void);
    int main(void)
    {
     printf("starting now: ");
     one_three();
     printf("done! ");
     return 0;
    }
    void one_three()
    {
     printf("one ");
     two();
     printf("three ");
    }
    void two()
    {
     printf("two ");
    }
  • 相关阅读:
    cocos2dx中的定时器及其分类
    cocos中BatchNode精灵集合的使用
    cocos2dx中的坐标体系
    cocos2dx中的背景图层CCLayerColor和渐变图层CCLayerGradient
    精灵的属性Zorder的设置
    cocos2.2.3中创建精灵对象的三大类方法
    什么是差值查找?
    vs2013中头文件中大小写的切换的快捷键
    ARM基础:为何C语言(的函数调用)需要堆栈,而汇编语言却不需要堆栈
    ARM基础:MMU 异常向量表 重映射
  • 原文地址:https://www.cnblogs.com/TomLily/p/5814589.html
Copyright © 2011-2022 走看看