Professional Documents
Culture Documents
C Prog
C Prog
C Prog
int main()
{
//Sum of squares of digits of the number
int sqdNumber,sqdNumber_result;
cout << "Enter a number" << endl;
cin >> sqdNumber;
//// --------------------------------------------------------------------------//// BEGIN: Write code to calculate sum of square of the number (marks = 1) DON
T_ERASE_02_01
//// Store the computed (sum of the squares of the digits) in 'sqdNumber_result'
sqdNumber_result=0;
while(sqdNumber>0)
{
int temp;
temp=sqdNumber%10;
sqdNumber_result=sqdNumber_result+ temp*temp;
sqdNumber=sqdNumber/10;
}
//// END: Code to calculate sum of square of the number option DONT_ERASE_02_01
//// --------------------------------------------------------------------------cout << "sum of the squares of the digits of the number 'sqdNumber' is " <<
sqdNumber_result << endl;
return 0;
}