Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- #2601
- Scrieți un program care calculează suma pătratelor cifrelor unui număr
- natural de trei cifre citit de la tastatură.
- *******************************************************************************/
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,s,c1,c2,c3;
- cout<<"Introduceti numarul de 3 cifre : ";
- cin>>n;
- c1=n%10;
- c2=(n/10)%10;
- c3=n/100;
- s=(c1*c1)+(c2*c2)+(c3*c3);
- cout<<"Suma patratelor cifrelor numarului "<<n<<" este "<<s<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment