Thursday, 24 January 2013

Array Sum

#include <iostream>

using namespace std;

int main()
{
    int sum=0;


    int j;
    cout << "How many numbers you want to add";
cin >> j;
    int x[j];


    for(int i=0; i<=j;i++)
    {

cin >> x[i];
sum=sum+x[i];


    }
cout << "The sum is = "<< sum;

  cin.get();
   return 0;
}




0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management