/*program uses a fubction to divide one
digit by another*/
#include<stdio.h>
#include<conio.h>
/*declaring function*/
float div(float,float);
main()
{
float dig1=0,dig2=0,result=0;
printf("Please enter a number: ");
scanf("%f",&dig1);
while(dig2 == 0)
{
printf("\n\n\nNow enter a number to
divide first digit: ");
scanf("%f",&dig2);
if(dig2==0)
{
printf("\tWarning!\nDenominator can not be zero.");
}
}
/*calling function and storing rturned value in variable
result*/
result
= div(dig1,dig2);
printf("%f / %f = %f",dig1,dig2,result);
getche();
return 0;
}
/*Defining function*/
float div(float digi1, float digi2 )
{
float opert;
opert =
digi1 / digi2;
return opert;
}
No comments:
Post a Comment