C Program with Algorithm to find the smallest among given 3 numbers using nested if.


#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,n3;
clrscr();
printf("\nEnter the 3 numbers\n\n\tNumber1\t: ");
scanf("%d",&n1);
printf("\n\tNumber2\t: ");
scanf("%d",&n2);
printf("\n\tNumber3\t: ");
scanf("%d",&n3);
if(n1<n2)
{
if(n1<n3)
   printf("\nThe First number '%d' is Smallest",n1);
}
if(n2<n1)
{
if(n2<n3)
printf("\nThe Secound number '%d' is smallest",n2);
}
if(n3<n1)
{
if(n3<n2)
printf("\n The Third number '%d' is smallesr",n3);

}
getch();
}

Algorithm
step 1: Start
step 2: Read n1,n2,n3;
step 3: if n1<n2 ,then go to step 4
else go to step 6
step 4: if n1<n3, then go to step 5
else go to step 6
step 5: print n1
step 6: if n2<n1 ,then go to step 7
else go to step 9
step 7: if n2<n3, then go to step 8
else go to step 9
step 8: print n2
step 9: if n3<n1 ,then go to step 10
else go to step 12
step 10: if n3<n2, then go to step 11
else go to step 12
step 11: print n3
step 12: Stop