#include <stdio.h>
#include <stdlib.h>
void main()
{
double *ary; //will be your dynamic 1d array
int num; //your array element
//input your number of array element
printf("num: ");
scanf("%d", &num);
//syntax: number of block address times byte needed (sizeof) for double variable
ary = malloc(num * sizeof(double));
//fill the array (can be changed to any number) and display them
for(int i=0; i<num; i++)
{
ary[i] = i * i * 2.8;
printf("%.2f\n", ary[i]);
}
//must free the memory allocation to not make memory leak
if(ary) free(ary);
}
dynimcally allocated array 2
Tuesday, May 30, 2017
You Might Also Like
centripetal parametrization for curve fitting or interpolation
1. playing with string manipulation, 2. function to sort dynamically alocated string array in visual c++
Simple basic archimedean spiral code implementation
Simple basic spiral code implementation 2 with tolerance 0.1
compute derivative coefficient of n-th degree polynomial equation
Browser Comparison: Firefox quantum vs Chrome
Subscribe to:
Post Comments (Atom)
No comments