SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. float findNumberMax(float [10]);
  5. float findMax(float a[10]);
  6.  
  7. void main()
  8. {
  9.     float a[10];
  10.     int i;
  11.     float sum = 0;
  12.  
  13.     printf("Input elements of array");
  14.  
  15.     for (i = 0; i < 10; i++)
  16.     {
  17.         printf("a[%d] = ", i);
  18.         scanf("%f", &a[i]);
  19.     }
  20.  
  21.     for (i = findNumberMax(a[10]); i < 10; i++)
  22.     {
  23.         if (a[i] > (findMax(a[10]) / 2) && (i - findNumberMax(a[10])) % 2 == 0)
  24.         {
  25.             sum += a[i];
  26.         }
  27.     }
  28.  
  29.     printf("%f", sum);
  30. }
  31.  
  32. int findNumberMax(float a[10])
  33. {
  34.     int maxi;
  35.  
  36.     for (int i = 0; i < 10; i++)
  37.     {
  38.         if (a[i] = findMax(a[10]))
  39.         {
  40.             maxi = i;
  41.         }
  42.     }
  43.  
  44.     return maxi;
  45. }
  46.  
  47. float findMax(float a[10])
  48. {
  49.     double max = (-1)*pow(10,38) - 1;
  50.  
  51.     for (int i = 0; i < 10; i++)
  52.     {
  53.         if (a[i] > max)
  54.         {
  55.             max = a[i];
  56.         }
  57.     }
  58.  
  59.     return max;
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top