Question: Find the largest entered item using Dynamic Memory Allocation. Sample input and output: Pointer : Find the largest number by Dynamically Allocating Memory : Enter

Find the largest entered item using Dynamic Memory Allocation.
Sample input and output:
Pointer : Find the largest number by Dynamically Allocating Memory :
Enter total number of items: 5
Number 1: 3
Number 2: 2
Number 3: 9
Number 4: 4
Number 5: 10
The Largest item is : 10.00
Skeleton:
#include
#include
int main()
{
int i,n;
float *item;
printf("
Pointer : Find the largest number by Dynamically Allocating Memory:
");
printf("--------------------------------------------------------------------------
");
printf("Input total number of items: ");
scanf("%d",&n);
// allocate the memory for item using malloc
item=(float *)malloc(n*sizeof(float *));
// if item is NULL then print no memory allocated
if(item==NULL)
{
printf("No memory allocated.");
exit(0);
}
// if memory is allocated then perform below operations
printf("
");
// take input for each number using (item+i) which is same as &item[i]
for(int i=0;i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!