帮助解决C中的加法问题 [英] help solving addition problem in C

查看:67
本文介绍了帮助解决C中的加法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个汉堡

val = 99999;

我想添加val的内容,即9 + 9 + 9 + 9 + 9 = 45;


怎么做....

急需帮助

解决方案

< blockquote> 10月14日,11:30 * am,@


| - |。 DUBEY" < dubey.ashw ... @ gmail.comwrote:


i有一个整数

val = 99999;

和我想添加val的内容,即9 + 9 + 9 + 9 + 9 = 45;


怎么做....

需要紧急帮助



取一个临时变量来存储总和并将其初始化为零,

现在通过递归取模数和除法你可以每个数字

数字分开,你可以继续添加数字..,


10月14日,11:39 * am ,Pranav< pranav ... @ gmail.comwrote:


10月14日,11:30 * am,@


i have a interger
val = 99999;
and i want to add the content of val i.e., 9+9+9+9+9 = 45;

how to do that....
need urgent help

解决方案

On Oct 14, 11:30*am, "@


|-|. DUBEY" <dubey.ashw...@gmail.comwrote:

i have a interger
val = 99999;
and i want to add the content of val i.e., 9+9+9+9+9 = 45;

how to do that....
need urgent help

take a temporary variable to store sum and initialize it to zero,
Now by recursively taking modulus and dividing the number you can each
digit separated and you can go on adding the digit..,


On Oct 14, 11:39*am, Pranav <pranav...@gmail.comwrote:

On Oct 14, 11:30*am, "@


这篇关于帮助解决C中的加法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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