Array : Dynamic

/* A dynamically-allocated 1-D array */
#include <stdio.h> int main (void) { double* array; /* declare a pointer only */ int i, size; /* ask user for size of array */ printf ("How large do you want your array? "); scanf ("%d", &size); /* allocate the array in the heap */ array = (double *) calloc (size, sizeof(double)); /* printing the array for verification surprise! a dynamic array is automatically initialized with zeros! */ for (i = 0; i < size; ++i) printf ("%6.2lf", array[i]); /* freeing the memory allocation */ free (array); return (0); }

12 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. //A dynamically-allocated 1-D array
    include (stdio.h)
    int main (void)
    {
    double *in;
    int i=0, n;
    printf ("Input size of array:");
    scanf ("%d", &n);
    in=(double*) calloc (n, sizeof(double));
    while(i<n)
    {
    printf ("%5.2lf ", in[i]);
    i++;
    }

    getch();
    }

    ReplyDelete
  3. #include
    using namespace std;
    int main()
    {
    int i,n;
    cout<<"Enter Your array size"<>n;
    for(i=0;i<n;i++)
    cout<<i<<endl;
    }


    ReplyDelete
  4. #include
    int main ()
    {
    double *at;
    int i=0, b;
    printf ("Input size of array:");
    scanf ("%d", &b);
    at=(double*) calloc (b, sizeof(double));
    while(i<b)
    {
    printf ("%3.11f ", at[i]);
    i++;
    }

    getch();
    }

    ReplyDelete
  5. #include
    int main ()
    {
    double *at;
    int i=0, b;
    printf ("Input size of array:");
    scanf ("%d", &b);
    at=(double*) calloc (b, sizeof(double));
    while(i<b)
    {
    printf ("%3.11f ", at[i]);
    i++;
    }

    getch();
    }

    ReplyDelete
  6. ID : 201620195
    https://www.dropbox.com/s/a5vbhbet38rmr0w/02.cpp?dl=0

    ReplyDelete
  7. ID:201610456
    solution link->
    https://drive.google.com/open?id=16fQ5XMAgFG1k6hmUSv7ve8-rC6pnRMuOQW2hyf9sgW4

    ReplyDelete
  8. 2)Array_Dynamic
    https://drive.google.com/open?id=0B5pG0kIjzgEKZjVRLXI2VUo3Skk

    ReplyDelete
  9. ID: 201710494
    https://www.dropbox.com/s/rrk13m52yin4o3k/2Dynamic%20Array.cpp?dl=0

    ReplyDelete
  10. https://drive.google.com/open?id=0B3bVD5Ppt_STa1hIZWJIWi1Kb3M

    ReplyDelete
  11. https://drive.google.com/open?id=0B3bVD5Ppt_STRlRNVmx0UVJfWVU

    ReplyDelete
  12. #include
    #include
    using namespace std;

    class a
    {
    public:
    a()
    {
    cout<<"Enter a value:";
    }
    };
    class b
    {
    public:
    b()
    {
    cin>>n;
    p=(int*) malloc(sizeof(int)*n);
    for(i=0;i>p[i];
    }
    }
    protected:int i,n,*p;
    };
    class c:public a,public b
    {
    public:
    c()
    {
    for(i=0;i<n;i++)
    {
    cout<<p[i]<<endl;
    }
    }
    };
    int main()
    {
    c obj;
    return 0;
    }

    ReplyDelete