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
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item