Advertisement
sherry_ahmos

Untitled

Feb 18th, 2022
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <cstdlib>
  4. #include <bits/stdc++.h>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8. void sum(int n,long long s ){
  9.     long long sum=0;
  10.      while(s>0){
  11.         int temp=s%10;
  12.         sum+=temp;
  13.         s/=10;
  14.      }
  15.      cout<<sum;
  16. }
  17.  
  18. int main()
  19. {
  20.     int n;
  21.     cin>>n;
  22.     long long s;
  23.     cin>>s;
  24.     sum(n,s);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement