Write ac program to accept 10 numbers from user and find the smallest number using pointer

#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,n,a[50];
int *p,small;
clrscr();
printf("\n enter the limit\n");
scanf("%d",&n);
printf("\n enter the matrix elements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
p=&a[0];
for(i=0;i<n;i++)
{
printf("\n%d",*(p+i));
}
small=*(p+i);
for(i=0;i<n;i++)
{
if(*(p+i)<small)
{
small=*(p+i);
}
}
printf("\n small number=%d",small);
getch();
}

No comments:

Post a Comment