Mar
22
#include<stdio.h>
#include<alloc.h>
void main(){
int *ptr;
int n,i,grt,smt;
printf(“How many numbers you want to enter: “);
scanf(“%d”,&n);
ptr=(int*) malloc(n*sizeof(int));
printf(“Enter %d numbers: \n”,n);
for(i=0;i<n;i++){
scanf(“%d”,(ptr+i));
}
grt=*ptr;
smt=*ptr;
for(i=0;i<n;i++){
if(*(ptr+i)>grt)
grt=*(ptr+i);
if(*(ptr+i)<smt)
smt=*(ptr+i);
}
printf(“Greatest Number among entered %d numbers is: %d\n”,n,grt);
printf(“Smallest Number among entered %d numbers is: %d\n”,n,smt);
printf(“Diff between Smallest and Greatest Number is: %d\n”,(grt-smt));
}
Leave a Reply
No Comments