0

Given a variable 'x' with value 1234 .Write a program to find the sum of the digits in 'x'.

11th Sep 2017, 4:14 PM
Adarsh Ps
Adarsh Ps - avatar
2 Answers
+ 2
#include <iostream> using namespace std; int main() {         int n,r,x=0;         cout<<"Your Numbers: ";         cin>>n;                 while(n>0)         {             r=n%10;             x=r+x;             n=n/10;                     }                 cout<<"Sum of that Number is :"<<x;           return 0; }
11th Sep 2017, 4:58 PM
Shoron Shirogami
Shoron Shirogami - avatar
0
std::cout << 10;
11th Sep 2017, 4:19 PM
Schindlabua
Schindlabua - avatar