/* A Program that reads a six digit
integer and prints the sum of its six digit using Arithmatic operators. */
#include<iostream>
using namespace std;
int print_sum_of_digit(int number)
{
int a,i,sum=0,count=0;
if(number!=0)
{
while(number>0)
{
i=number%10;
number=number/10;
sum+=i;
count++;
}
cout<<"Number of Digit:"<<count<<endl;
return sum;
}
}
int main()
{
int number,i;
cout<<"Enter the digit of six integer:"<<endl;
cin>>number;
cout<<"The sum of the digit is:"<<print_sum_of_digit(number)<<endl;
return 0;
}
No comments:
Post a Comment
Comment Here