//write a program whih takes input until user enters a negative number. print the sum of given inputs.
#include <iostream>
using namespace std;
int main ()
{ int a[10];
cout << " enter numbers " << endl ;
int i = 0 ;
while ( i < 10)
{while (a[i] > 0 ) {cin>>a[i];}
i++;}
int sum = 0;
i = 0 ;
while ( i < 10 )
{sum=sum+a[i];
i++;}
cout<< " sum is " <<sum;
system ("pause");
return 0 ;
}
maiza.razzaq 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.