Advertisement
Utkar5hM

Babu

Feb 23rd, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void sum(int &sm, int &N, int &n){
  4.     int a(0);
  5.     scanf("%d",&a);
  6.     sm += a;
  7.     if(n<N){
  8.         ++n;
  9.         sum(sm, N,n);
  10.     }
  11. }
  12. int main() {
  13.         int N =0;
  14.     cin >>N;
  15.     int n=1;
  16.     int sm=0;
  17.     sum(sm, N,n);
  18.     cout << sm;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement