0
Given a variable 'x' with value 1234 .Write a program to find the sum of the digits in 'x'.
2 Antworten
+ 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;
}
0
std::cout << 10;