31. Write a flow chart to accept a number and display sum of square of its individual
digits.
3
(for example: if user enters 123 then output should be 12 + 22 + 32 = 14]
Answers
Explanation:
Leaving out the somewhat ridiculous and sometimes shameful religious slant towards this question, you would think that the purpose of humans is to find ways to work cooperatively to maintain the earth and its resources so that all of us have clean water and air, comfortable housing and clothing, adequate healthcare, and equal opportunities for work and education, and amenities such as transportation, communication, entertainment, and recreation. We should be able to do all this without polluting or spoiling the earth, which is, of course, the mother of all of us.
Program in C++
#include<iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter a number : ";
cin>>n;
int sum = 0;
while(n != 0)
{
int d = n % 10;
int s = d * d;
sum = sum + s;
n = n / 10;
}
cout<<"Sum of square of its individual digits = "<<sum;
return 0;
}
Output:
Enter a number : 123
Sum of square of its individual digits = 14