Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <time.h>
- using namespace std;
- const int n=10;
- int main()
- {
- float a[n],sum,min,min2;
- for (int i=0; i<n; i++){
- a[i] = rand() %100 - 55;
- cout << a[i] << " ";
- }
- cout <<endl;
- for (int i=0; i<n; i++){
- if (a[i]<0){
- min=i+1;
- break;
- }
- }
- for (int i=0; i<n; i++){
- if (a[i]<0){
- min2=i;
- }
- }
- for (int i=min;i<min2;i++){
- sum+=a[i];
- }
- cout<<sum;
- cout <<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment