193030

Number digits powering

May 8th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include<fstream>
  2. #include <vector>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     int n = 10;
  10.     int sum =0;
  11.     int m = 0;
  12.     for(int i =0; i<100000; i++)
  13.     {
  14.         if((n/10)!=0)
  15.         {
  16.             m = n%10;
  17.             n = n/10;
  18.             sum = m*m;
  19.  
  20.         }
  21.         else{
  22.             m = n;
  23.             sum =sum+ m*m;
  24.             break;
  25.         }
  26.  
  27.     }
  28.     cout << sum;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment