SUM OF THE SQUARE OF THE DIGIT OF THE NUMBER


SUM OF THE SQUARE OF THE DIGIT OF THE NUMBER:
#include<studio.h>
#include<conio.h>
int main()
{
int no, temp, sum=0;
clrscr ();
prints("ENTER THE NUMBER: \n");
scanf("%d",&no);
while(no/10!=0)
{
temp=no%10;
sum=sum+temp*temp;
no=no/10;
}
sum=sum+no*no;
printf("sum=%d", sum);
getch();
return 0;
}
___________________________________________________________________
Output:
ENTER THE NUMBER:786
sum=149



SUM OF THE SQUARE OF THE DIGIT OF THE NUMBER SUM OF THE SQUARE OF THE DIGIT OF THE NUMBER Reviewed by Amit Waghmare on October 07, 2018 Rating: 5

No comments: