Write a c program to find maximum & minimum elements using Pointers.

#include<stdio.h> #include<conio.h> main() { Int i, n,min,max a[10]; int * p; printf(“enter how many elements”); ...

#include<stdio.h>
#include<conio.h>
main()
{
Int i, n,min,max a[10];
int *p;
printf(“enter how many elements”);
scanf(“%d”, &n);
printf(“enter elements”);
for(i=0;  i<n; i++)
scanf(“%d", &a[i]);
p=&a[0];
min=*p, max = *p;
for (i=0; i<n; i++)
{
if(*p<min)
min = *p;
if(*p>max)
max=*p;
p++;
}
printf(“max=%d \t  min=%d”, max,min);
getch();

}

Related

C Programs 8037411898709432332

Post a Comment

emo-but-icon

item