第五章 运算符,表达式和语句

第五章  运算符,表达式和语句

1.     表达式树。来表示赋值的程序。


2.      sizeof的返回值类型是  size_t 类型。size_t类型是一个无符号整数类型。


3.     ++i和 i++    -- 一样。

     aplus = a++  使用a 的值之后改变a。(a++)
   aplub = ++b  改变b的之后使用b.


第六章  C控制语句:循环
关键字:for while do while。
函数 fabs()
循环中的常用数组。
编写具有返回值的函数。
1. while  和 scanf()的组合使用。while(scant(“%d”,&num)==1)
2. fabs()求一个数或者一个运算式的绝对值。
3. n = -3;
4. while(n)
5.  printf("%2d is true." n);
         printf("%2d is false." n);


6.    关于判读语句的一些错误写法和一些防止错误写法的小技巧

·      比较和赋值 的区别:


·

· 如果是这样的话,很巧妙的躲开了少一个=的bug。


· 关系运算符:优先级高的先执行,如果优先级相同,执行从左到右的顺序。






7.getchar()和putchar()
    
   while((ch = getchar()))
    {
        if(ch == ' ')
            putchar(ch);
        else
            putchar(ch+1);
        
    }


8.  ctype.h  字符判断函数



9.iso646.h文件中 宏定义了  && == and ,|| = or,! = not

10.







11.continue 和break、
     对于for循环来说:
int main(int argc, const char * argv[])
{
    int i;
    
    for(i = 0 ; i < 10;i++)
    {
         if(i == 3)
             break;
          // continue;
        printf("%dHello, World!\n",i);
    }
 
    return 0;
}


//while
while(i-- > 0)
    {
         if(i == 3)
            // break;
           continue;
        printf("%dHello, World!\n",i);
        
    }
结果和下面的一样。


break:
0Hello, World!
1Hello, World!
2Hello, World!
continue:
0Hello, World!
1Hello, World!
2Hello, World!
4Hello, World!
5Hello, World!
6Hello, World!
7Hello, World!
8Hello, World!
9Hello, World!
12.


13.swtich的例子。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值