# C Program To Find Largest And Smallest Number Among N Numbers

In this article, we are going to **write a c program to Largest And Smallest Number Among N Numbers**

We will make this program in the following way -:

- C Program To Find Largest And Smallest Number Among N Numbers (Simple Way)
- C Program To Find Largest And Smallest Number Among N Numbers Using Function

To make this program, we will use the following concept -:

If you do not know about these topics well, then you may not understand this program, so you should know about them in detail from the link given above.

Now without wasting time letâ€™s start programming.

## C Program To Find Largest And Smallest Number Among N Numbers Using Pointer

**Program -:**

```
//C Program To Find Largest and Smallest among n Numbers
#include<stdio.h>
void main()
{
int i,*ptr, n,a[100],larg,small;
printf("Enter How many number you want?:\n") ;
scanf("%d",&n) ;
printf("Enter %d numbers\n",n) ;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]) ;
}
ptr = &a[0];
larg= *ptr;
for(i=0;i<n;i++,*ptr++)
{
if(*ptr>larg)
{
larg=*ptr;
}
}
ptr = &a[0];
small= *ptr;
for(i=0;i<n;i++,*ptr++)
{
if(*ptr<small)
{
small=*ptr;
}
}
printf("Largest Number is %d \n",larg);
printf("Smallest Number is %d",small);
}
```

**Output -:**

```
Enter How many number you want?:
3
Enter 3 numbers
1
2
3
Largest Number is 3
Smallest Number is 1
```

## C Program To Find Largest And Smallest Number Among N Numbers Using Function

**Program -:**

```
//C Program To Find Largest and Smallest among n Numbers
#include<stdio.h>
void sl(int n)
{
int i,*ptr,a[100],larg,small;
printf("Enter numbers\n") ;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]) ;
}
ptr = &a[0];
larg= *ptr;
for(i=0;i<n;i++,*ptr++)
{
if(*ptr>larg)
{
larg=*ptr;
}
}
ptr = &a[0];
small= *ptr;
for(i=0;i<n;i++,*ptr++)
{
if(*ptr<small)
{
small=*ptr;
}
}
printf("Largest Number is %d \n",larg);
printf("Smallest Number is %d ",small);
}
void main()
{
int n;
printf("Enter How many number you want?:\n") ;
scanf("%d",&n) ;
sl(n);
return 0;
}
```

**Output -:**

```
Enter How many number you want?:
3
Enter 3 numbers
11
22
33
Largest Number is 33
Smallest Number is 11
```

**Read More **

- Download C Language Notes Pdf
- C Language Tutorial For Beginners
- C Programming Examples With Output
- 250+ C Programs for Practice PDF Free Download

## Conclusion

In this article, we have created all the following programs** -:**

- C Program To Find Largest And Smallest Number Among N Numbers (Simple Way)
- C Program To Find Largest And Smallest Number Among N Numbers Using Function

If you have difficulty to understand any program or have any doubts or questions, then tell me in the comment below.