Ok...I'm commenting on your code on post #7 ...
Do accordingly... and it'll be ok.
Code:
#include <iostream>
using namespace std;
//void explanation();
int sums;
int main()
{
explanation();
int nums[10] = {1,2,3,4,5,6,7,8,9,10};
int i;
int *ptr; //Why do you need these ?
ptr=0; //^
ptr=&nums[10];//^
printf("The numbers in the array are: \n"); //Try using C++ style I/O ..
for (i=0; i < 10; i++)
{
printf("%d ", nums[i]);
}
for (i=0; i <= 10; i++) //< instead of <= ...as indices are from 0 to n-1
{
int sums=0;//Put this statement above the loop.
sums += nums[i];
}
printf("\n");
printf("The sum of the elements are: ");
printf("\n");
printf("%d", sums);
printf("\n");
return 0;
}
Also.. just to tempt you towards using the modern C++ features..watch the following code..(Note that you'll need a C++11 compatible compiler)
Code:
#include<array>
#include<iostream>
using namespace std;
int main()
{
array<int,10> nums={1,2,3,4,5,6,7,8,9,10};
int sum(0);
for(auto x:nums)
{
cout<<x<<'\t';
sum+=x;
}
std::cout<<"\nSum= "<<sum;
cin.get();
return 0;
}