Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: C  |  size: 0.33 KB  |  views: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int sum_of(int num)
  6. {
  7.         int i,result = 0;
  8.     for(i=1;i<=num;i++)
  9.         {
  10.                 result=result+i;
  11.         }
  12.        
  13.         return result;
  14. }
  15.  
  16. int main()
  17. {
  18.         int sum = 0, i, num = 0;
  19.         for(i=0;i<10;i++)
  20.         {
  21.                 cin>>num;
  22.                 sum=sum+sum_of(num);
  23.         }
  24.         cout<<"The Sum is: "<<sum;
  25.         system("Pause");
  26.         return 0;
  27. }