NEP -DATA STRUCTURE

PART-A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8

PART-B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

5.Write a C Program to implement dynamic array, find smallest and largest element of the array

 
  
 
 
 
 

/*Write a C Program to implement dynamic array, find smallest and largest element of the
array*/


#include< stdio.h >

int main()
{
int *myarray,i,n,large,small;
printf(“\nEnter the number of elements : “);
scanf(“%d”,&n);

myarray=(int*)malloc(size * sizeof(int));
printf(“\nInput the array elements : “);
for(i=0;i< n;++i)
scanf(“%d”,&myarray[i]);

large=small=a[0];

for(i=1;i< n;++i)
{
if(a[i] > large)
large=myarray[i];

if(a[i]< small)
small=myarray[i];
}

printf(“\nThe smallest element is %d\n”,small);
printf(“\nThe largest element is %d\n”,large);

return 0;
}