[ create a new paste ] login | about

Link: http://codepad.org/Wd2lLDM7    [ raw code | output | fork ]

C++, pasted on Dec 9:
#include <iostream>
#include <ctime>
 
using namespace std;
 
int main()
{
        srand(static_cast<int>(time(NULL)));
        int *arr;
        int sum=0,size;
        cout<<"Enter size of array: ";
        size=10;
        arr = new int[size];
        cout<<endl<<"Array: "<<endl;
        for(int i=0; i<size; i++)
        {
                    arr[i]=rand()%5-2;
                        cout<<arr[i]<<"  ";
                        sum+=arr[i];
        }
     cout<<endl<<"Sum is "<<sum<<endl;  
   delete [] arr;
   system("pause");
   return 0;
}


Output:
1
2
3
4
5
6
Enter size of array: 
Array: 
2  -1  -2  2  2  2  0  2  -1  -1  
Sum is 5

Disallowed system call: SYS_fork


Create a new paste based on this one


Comments: