Find largest number in c language without using any loop with examples.
int maxnumber(int num1, int num2, int num3)
{
int largestnumber;
largestnumber=int num1; /* Assume number 1 is largest number*/
if (num2 > largestumber)
{
largetnumber=num2; /* number 2 is largest number*/
}
if (num3 > largestnumber)
{
largestnumber=num3;
}
return largestnumber;
}
we can do this by using for loop but here i have shown how to find out largest number using
if statement.
int maxnumber(int num1, int num2, int num3)
{
int largestnumber;
largestnumber=int num1; /* Assume number 1 is largest number*/
if (num2 > largestumber)
{
largetnumber=num2; /* number 2 is largest number*/
}
if (num3 > largestnumber)
{
largestnumber=num3;
}
return largestnumber;
}
we can do this by using for loop but here i have shown how to find out largest number using
if statement.
0 comments: