Advertisement
icatalin

Untitled

Nov 21st, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. //Se citeste un nr n. Afisati suma cifrelor numarului care se afla doar pe pozitii impare.
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int n,s=0,cif;
  10. cout<<"n=";
  11. cin>>n;
  12. while (n!=0)
  13. {
  14. cif=n%10;
  15. n=n/100;
  16. s=s+cif;
  17. }
  18. cout<<"s="<<s;
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement