-->

program to print smallest number among three numbers using function.

using codeblock
--------------------------------------------------------------------------------------------------------------------
//to print smallest number among three numbers using function.
#include<stdio.h>                      //header file
void smallest();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
smallest();                                     // function calling.
return 0;                                       //returns 0 value
}
void smallest()                              // function body line ; also called function definition
{
 float number1,number2,number3;                    // variable declaration 
printf("enter three numbers\n");           // displays message to input data
scanf("%f%f%f",&number1,&number2,&number3);        // gets data from user.
if(number1>number2 &&number1>number3)                     //condition testing
{
printf("%f is greater\n",number1);    // displays output
}
else if(number2>number1 &&number2>number3)
{
    printf("%f is greater\n",number2);    // displays output for second condition
}
else
{
   printf("%f is greater\n",number3); 
}

}

--------------------------------------------------------------------------------------------------------------------------
using turbo C++
-----------------------------------------------------------------
//to print smallest number among three numbers using function.
#include<stdio.h>                      //header file
#include<conio.h>
void smallest();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
smallest();                                     // function calling.
getch();                                       //returns 0 value
}
void smallest()                              // function body line ; also called function definition
{
 float number1,number2,number3;                    // variable declaration 
printf("enter three numbers\n");           // displays message to input data
scanf("%f%f%f",&number1,&number2,&number3);        // gets data from user.
if(number1>number2 &&number1>number3)                     //condition testing
{
printf("%f is greater\n",number1);    // displays output
}
else if(number2>number1 &&number2>number3)
{
    printf("%f is greater\n",number2);    // displays output for second condition
}
else
{
   printf("%f is greater\n",number3); 
}

}

No comments:

Post a Comment