Facebook
From asd, 6 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 220
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<math.h>
  4.  
  5. int main()
  6. {
  7.  
  8.     signed int sumOfElements,amountOfElements,iterator,stoper;
  9.     printf("Podaj liczbe n, czyli ile maksymalnie moze byc zliczonych liczb\n");
  10.     scanf("%d",&amountOfElements);
  11.     int array[amountOfElements];
  12.     printf("Podaj liczbe stoper\n");
  13.     scanf("%d",&stoper);
  14.     printf("Podaj te liczby :)\n");
  15.     for(iterator =0; iterator<amountOfElements; iterator++)
  16.     {
  17.         scanf("%d",&array[iterator]);
  18.         if(array[iterator]==stoper){
  19.             break;
  20.         }
  21.  
  22.     }
  23.  
  24.     iterator = 0;
  25.     sumOfElements = 0;
  26.     while(iterator<amountOfElements)
  27.     {
  28.         if(array[iterator]>=-99 && array[iterator]<=-10)
  29.         {
  30.             sumOfElements = sumOfElements + array[iterator];
  31.         }
  32.         ++iterator;
  33.     }
  34.  
  35.     printf("%d",sumOfElements);
  36.  
  37.     return 0;
  38. }
  39.  
  40.