Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {          
  5.     int a, b=0, c=0, sum = 0;
  6.     cout << "Input number :"; cin >> a;
  7.     while (a!=0)
  8.     {
  9.        
  10.         b = a / 10;
  11.         c = a - b * 10;
  12.         if (c % 2 != 0)
  13.         {
  14.             sum += c * c;
  15.             a = b;
  16.         }
  17.        
  18.     }
  19.     cout << sum;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement