码迷,mamicode.com
首页 > 其他好文 > 详细

2.3.1 基本数据类型和运算符

时间:2016-02-21 21:09:11      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:

  1 在C语言中,要求运算对象必须是整型的运算符是

  2 int i = j = 5;→这个定义方法是错的note: each undeclared identifier is reported only once for each function it appears in。/* int i =5, j = 5;是对的。 */ 

  3 将整型a,b中较大的数复制给整型c:c =  (a>b)? a : b; √ 

  4 在C语言中,退格符是 \b :

  5 int a = 7; float x = 2.5,y = 4.7; 则表达式 x + a % 3 * ( int ) ( x + y ) % 2 / 4 的值是: 2.50000

  6 int x , i , j ,k; 则x = ( i = 4, j = 16, k = 32 ); x 的值为: 32

1 int main()
2 {
3     int x,j,i,k;
4     x = (i = 4, j = 45 , k = 32);
5     printf("%d",x);
6 return 0;
7     
8     }
9 /*输出结果为32*/

 

  7 int x = 8, y = 3;问 printf("x = 8,y = 3\n x--:%d ,--y:%d\n",x--,--y); 的输出结果是多少?

 

 int x = 8, y = 3;
    printf("x = 8,y = 3\n x--:%d ,--y:%d\n",x--,--y);
    int a = 8 , b = 3; 
    printf("a = 8,b = 3\n a++:%d,++b:%d\n",a++,++b); 

/*
结果:
x = 8,y = 3
 x--:8 ,--y:2
a = 8,b = 3
 a++:8,++b:4
*/

  8 设有 int a = 1,b = 2,c = 3, d = 4 ,m = 2,n = 2;则执行语句( m = a > b ) && ( n = c > d );后n的值:

 int a = 1,b = 2,c = 3, d = 4, m = 2,n = 2;
   ( m = a > b ) && ( n = c > d );
   printf("%d",n); 

/*所得结果为2

*/

  9 已知 int a = 6; ,则执行 a += a- = a*a; 后,a的值为:

    int a = 6;
    a += a -= a*a;
    printf("a的值为:%d\n" , a);

/*
 a的值为: -60
a = 6-6*6
a + = a 

*/

  10 int x = 1,y = 1 , z = 1; 执行语句 ++x || ++ y && ++z ;后,求表达式 x + y的值:3 

int x = 1, y = 1, z = 1;
    int k = ++x || ++y && ++z;
    printf(" k = ++x || ++y && ++z, k = %d\n", k);
    printf("x = %d\n" , x);
    printf("y = %d\n" , y);
    printf("x+y = %d\n" , x+y);
    
    int j = ++y && ++z; 
    printf(" j = ++y && ++z, j = %d\n", j);
    printf("x = %d\n" , x);
    printf("y = %d\n" , y);
    printf("x+y = %d\n" , x+y);

/*
 k = ++x || ++y && ++z, k = 1
x = 2
y = 1
x+y = 3
 j = ++y && ++z, j = 1
x = 2
y = 2
x+y = 4

*/  

2.3.1 基本数据类型和运算符

标签:

原文地址:http://www.cnblogs.com/zanglie/p/5202524.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!