变量“total和sum3”的值是多少?独立执行以下两段代码后? [英] what will be the values for the variables "total and sum3" after executing the below two sections of the code independently?

查看:152
本文介绍了变量“total和sum3”的值是多少?独立执行以下两段代码后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

// total and sum3 values must be same after execution of the below two c codes
void main()
{
int a=10;
int total;
printf("Value of a before ++a is :%d\n",a);
++a;
printf("Value of a after ++a is :%d\n",a);
total=(((++a)*(10))+((++a)*(10))+((++a)*(10)));/* total and sum3 values must be same after execution of the below two c codes*/
printf("Value of total is :%d\n",total );


int a=10;
int sum1,sum2,sum3;
printf("Value of a before ++a is :%d\n",a);
++a;
printf("Value of a after ++a is :%d\n",a);
sum1=((++a)*10); // here total is broken into sum1, sum2, sum3
sum2=(sum1)+((++a)*10);
sum3=(sum2)+((++a)*10);
printf("Value of sum1 is :%d\n",sum1 );
printf("Value of sum2 is :%d\n",sum2 );
printf("Value of sum3 is :%d\n",sum3 );
printf("Value of ++a at end is :%d\n",a);
}

推荐答案

即时消息总计= 400且sum3 = 390。但总数必须是390.请建议。
im getting total=400 and sum3=390. But total has to be 390. Please suggest.


这篇关于变量“total和sum3”的值是多少?独立执行以下两段代码后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆