#include <iostream>
int main ()
{
int num;
std::cout << "Input number: ";
std::cin >> num;
int count=0, sum=0;
while (num) {
count++;
sum+=num%10;
num/=10; }
std::cout << "Number: " << count;
std::cout << std::endl;
std::cout << "Sum: " << sum;
std::cout << std::endl;
system ("pause");
return 0;
}
Следующий вариант
#include <iostream>
using namespace std;
int sum(int a);
int ext(int a);
int main()
{ int x;
cout<<"Vvedite"<<endl;
cin>>x;
cout<<ext(x)<<" "<<sum(x)<<endl;
system("PAUSE");
}
int ext(int a)
{ int i=10,n=1;
while(a!=0)
{ a/=i;
i*=10;
n++;
}
return n-1;
}
int sum(int a)
{ int sum=a%10,i=10;
while(a!=0)
{ a/=i;
i*=10;
sum+=a;
}
return sum;
}