Advertisement
joyshree94

range er add

Feb 3rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include<stdio.h>
  2. int add(int a,int b,int m);
  3. int main()
  4. {
  5. int a,b;
  6. scanf("%d",&a);
  7. scanf("%d",&b);
  8. add(a,b,0);
  9. return 0;
  10. }
  11. int add(int a,int b,int m)
  12. {
  13.  
  14. if(a==b)
  15. {
  16. m=m+a;
  17. printf("%d",m);
  18. }
  19. else if(a<b)
  20. {
  21. m=m+a;
  22. add(a+1,b,m);
  23. }
  24. else if(b<a)
  25. {
  26. m=m+b;
  27. add(a,b+1,m);
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement