MohamedAbdel3al

Sum Digits

Jul 28th, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std ;
  4. typedef long long ll ;
  5. int main() {
  6. ios::sync_with_stdio(false) ; cout.tie(NULL) ; cin.tie(NULL) ;
  7. int n , sum = 0 ;
  8. cin >> n ;
  9. char arr[n] ;
  10. for (int i = 0; i < n; i++) cin >> arr[i] ;
  11. for (int i = 0; i != '\0'; i++) {
  12. sum += arr[i] ;
  13. }
  14. cout << sum ;
  15.  
  16. return 0;
  17. }
  18.  
  19.  
  20.  
Advertisement
Add Comment
Please, Sign In to add comment