Yesterday I went for an interview where I have been asked to create a program to find largest and smallest among 5 numbers without using array.
I know how to create
This is not an efficient answer but it still works
int a,b,c,d,e,largest;
if ((a>b) and (a>c) and (a>d) and (a>e))
{
largest=a;
}
else if ((b>a) and (b>c) and (b>d) and (b>e))
{
largest=b;
}
else if ((c>a) and (c>a) and (c>d) and (c>e))
{
largest=c;
}
else if ((d>a) and (d>c) and (d>a) and (d>e))
{
largest=d;
}
else
{
largest=e;
}
you can use similar logic to fid the smallest value