Computer Science, asked by jaiswalshreya99, 1 year ago

WAP in c++ to find the sum of square of digit of a number with output?

Answers

Answered by snigdhbhardwaj
2
#include<iostream.h>
void main()
{
int value, digit_keeper, sum=0;

cout<<"Enter a number"<<endl;
cin>> value;

for( int i= value ; i != 0 ; i = i/10)
{
digit_keeper = i%10;
sum += digit_keeper * digit_keeper;
}

cout<<"Sum of square of digits is "<<sum<<endl;

}

If you Turbo C++ then include <conio.h> header file in starting and also add getch() at end of program to see results.
Similar questions