Computer Science, asked by surajraj8020, 10 months ago

Write a c program to store n elements using dynamic memory allocation - calloc() and find the largest element'

Answers

Answered by Anonymous
1

please normally explain this question

Answered by amrkononamnai
0

Answer:

#include <stdio.h>

#include <stdlib.h>

int main()

{

   int i, num;

   float *res;

   printf("Input size of array: : ");

   scanf("%d", &num);

   res = (float*) malloc(num* sizeof(float));

if(res == NULL)

   {

       printf("\nError! memory not allocated.");

       exit(0);

   }

    printf("\nArray element: ");

   for(i = 0; i < num; ++i)

   {

      scanf("%f", res + i);

   }

   for(i = 1; i < num; ++i)

   {

      if(*res < *(res + i))

          *res = *(res + i);

   }

   printf("\nExpected Output: = %.2f\n", *res);

   return 0;

}

Explanation:

This problem is solved  using dynamic memory allocation.

Similar questions