Sum of first 10natural numbers using C++
#include<iostream>
using namespace std;
int main()
{
//sum of first ten netural numbers.
int arr[10];
cout<<"Enter 10 numbers";
for(int i=0;i<=9;i++)
{
cin>>arr[i];
}
int sum=0;
for(int j=0;j<=9;j++)
{
sum=sum+arr[j];
}
cout<<sum;
return 0;
}
Comments
Post a Comment