C language max function and min, use function to get value, find max, find min and display in C language

These are actually two programs, but we need to combine it with a single program that has all 4 functions. The first function has to take the values ​​from both arrays and add and store them into the other array. The second function must find the largest element in the new array. The third function must find the smallest element in the new array. Finally, the fourth function must display all the values ​​of the above three functions, the element of the third array, which is the sum of the two arrays, then the largest element of the sum array and the smallest value of the sum array. The data item must be of external storage class. There is no compile error on Borland C, but the value is empty here.

It requires the concept of external storage classes, pointers to arrays and functions.

#include

#include

int a[10], b[10], *c[10], i, *min, *max;

void main()

{

//Function Prototypes

void getvalue(void);

void findmax(void);

void findmin(void);

void display(void);

getvalue();

findmax();

findmin ();

display();

getch();

}

void getvalue()

{

printf("\n Enter 10 values for Array A: ");

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

{

scanf("%d",a[i]);

}

printf("\n Enter 10 values for Array B: ");

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

{

scanf("%d",b[i]);

}

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

{

c[i]=a[i]+b[i];

}

}

void findmax()

{

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

{

if(*(c+0)<=*(c+i))

{

*(c+0) = *(c+i);

}

}

max = *(c+0);

}

void findmin()

{

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

{

if(*(c+0)>=*(c+i))

{

*(c+0) = *(c+i);

}

}

min = * (c + 0);

}

void display()

{

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

{

printf("\n\n The value of %d element of C = %d ",i,*(c+i) );

}

printf("\n\n The max value in C is %d",max);

printf("\n\n The min value in C is %d",min);

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324326427&siteId=291194637