Advertisement
RicardasSim

double array

Mar 20th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. //-std=c99 -Wall -Wextra -Wpedantic -Wshadow
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <stdint.h>
  6. #include <stdbool.h>
  7.  
  8. #define DARRSIZE 10
  9.  
  10. bool testas(double* arr, uint32_t num)
  11. {
  12.    
  13.     double dV = 0.0;
  14.    
  15.     for(uint32_t i = 0; i < 10; ++i)
  16.     {
  17.         if(num<=i) return false;
  18.            
  19.         *(arr+i) = dV;
  20.         dV += 1.0;
  21.     }
  22.    
  23.    
  24.     return true;
  25. }
  26.  
  27. int main (int argc, char **argv){
  28.  
  29.     double dArr[DARRSIZE]={0.0};
  30.    
  31.     if(!testas(dArr,DARRSIZE))
  32.     {
  33.         printf("error!\n");
  34.         return 1;
  35.     }
  36.    
  37.     for(uint32_t i =0; i < DARRSIZE; ++i)
  38.     {
  39.         //*(dArr+1) dArr[i]
  40.         printf("%f ",dArr[i]);
  41.     }    
  42.    
  43.     printf("\n");
  44.    
  45.     return 0;
  46. }
  47.  
  48. /*
  49. output:
  50.  
  51. 0.000000 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000
  52.  
  53. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement