Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Se citeste un nr n. Afisati suma cifrelor numarului care se afla doar pe pozitii impare.
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,s=0,cif;
- cout<<"n=";
- cin>>n;
- while (n!=0)
- {
- cif=n%10;
- n=n/100;
- s=s+cif;
- }
- cout<<"s="<<s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement