# C Program To Find Smallest Number Using Conditional Operator

In this article, we are going to **write a c program to find Smallest Number Using Conditional Operator** **or** **Ternary Operator.**

In this article, we will make the following programs -:

- C Program To Find Smallest of
**Two****Numbers**Using Conditional Operator - C Program To Find Smallest of
**Three****Numbers**Using Conditional Operator - C Program To Find Smallest of
**Four****Numbers**Using Conditional Operator - C Program To Find Smallest of
**Five****Numbers**Using Conditional Operator

- C Program To Find Smallest Number Using Conditional Operator
- C Program To Find Smallest of Two Numbers Using Conditional Operator
- C Program To Find Smallest of Three Numbers Using Conditional Operator
- C Program To Find Smallest of Four Numbers Using Conditional Operator
- C Program To Find Smallest of five Numbers Using Conditional Operator
- Conclusion

## C Program To Find Smallest Number Using Conditional Operator

To make and understand these programs well, first of all you need to know about conditional operator. You can read about the conditional operator in detail by clicking on the link given below.

Now without wasting time let’s start programming.

## C Program To Find Smallest of Two Numbers Using **Conditional** Operator

**Algorithm**

- Program Start
- Variable Declaration
- Input two number
- Check the condition, ternary (conditional) operator.
- Display answer according the condition
- Program End

**Program -:**

```
//C program to find Smallest among two numbers
//using Conditional operator or ternary operator
#include<stdio.h>
void main()
{
// Variable declaration
int a,b,small;
printf("Enter two number\n");
scanf("%d %d",&a,&b);
// Smallest among a and b
small = a<b?a:b;
//Display smallest number
printf("Smallest among 2 Number is : %d",small);
}
```

**Output -:**

```
Enter two number
12
17
Smallest among 2 Number is : 12
```

## C Program To Find Smallest of Three Numbers Using **Conditional** Operator

**Program** -:

```
//C program to find Smallest among three numbers
//using Conditional operator or ternary operator
#include<stdio.h>
void main()
{
// Variable declaration
int a,b,c,small;
printf("Enter Three Number\n");
scanf("%d %d %d",&a,&b,&c);
// Small among a, b and c
small = a<b?a<c?a:c:b<c?b:c;
//Display smallest number
printf("Smallest Among 3 Number is : %d",small);
}
```

**Output** -:

```
Enter Three Number
12
10
17
Smallest Among 3 Number is : 10
```

## C Program To Find Smallest of Four Numbers Using Conditional Operator

**Program** -:

```
//C program to find Smallest among four numbers using Conditional or ternary operator
#include<stdio.h>
void main()
{
// Variable declaration
int a,b,c,d,small;
printf("Enter four number\n");
scanf("%d %d %d %d",&a,&b, &c, &d);
// Smallest among a, b, c and d2
small = ( (a<b && a<c && a<d) ? a : (b<c && b<d) ? b : (c<d)? c : d );
//Display Smallest number
printf("Smallest Number is : %d",small);
}
```

**Output** -:

```
Enter Four Number
12
4
23
6
Smallest Number is : 4
```

## C Program To Find Smallest of five Numbers Using Conditional Operator

**Program** -:

```
//C program to find Smallest among five numbers using ternary operator
#include<stdio.h>
void main()
{
// Variable declaration
int a,b,c,d,e,small;
printf("Enter five number\n");
scanf("%d %d %d %d %d",&a,&b, &c, &d, &e);
// Smallest among a, b, c and d
small = ( (a<b && a<c && a<d && a<e) ? a : (b<c && b<d && b<e) ? b : (c<d && c<e)? c : (d<e)? d : e );
//Display Smallest number
printf("Smallest Number is : %d",small);
}
```

**Output** -:

```
Enter five number
12
4
32
5
3
Smallest Numbers is : 3
```

**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 using **Conditional Operator** **or** **Ternary Operator**

- C Program To Find Smallest Number Among Two Numbers Using Conditional Operator
- C Program To Find Smallest Number Among Three Numbers Using Conditional Operator
- C Program To Find Smallest Number Among Four Numbers Using Conditional Operator
- C Program To Find Smallest Number Among Five Numbers Using Conditional Operator

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

How to find the smallest number without using conditional operator