How to create a function that divides two numbers into C? [closed]

-5

How to create a function that divides two numbers into C?

    
asked by anonymous 01.06.2018 / 01:09

3 answers

0

include

int f_divisao (float num1, float num2) / ** function creation ** / {     float result;     result = num1 / num2;

printf("VALOR DA DIVISÃO DE %f / %f EH: %.2f\n",num1,num2,resultado);  /** saida de dados **/

return(f_divisao);

}

int main () {

float num1,num2;

printf("DIGITE OS DOIS VALORES:\n");
scanf("%f%f",&num1,&num2);  /** entrada de dados **/

f_divisao(num1,num2);  /** retorna os valores para a função f_divisao **/

} // See this one I did!

    
02.06.2018 / 07:53
1

More briefly this is how:

float dividir(float a, float b)
{
float c=a/b;
return c;
}

This way I put float function in case it will return a float to main. Oh, it's just you do the assignment ... type float d=dividir(a,b) I hope I have helped you!

    
01.06.2018 / 01:18
1

ideone

int a = 5, b = 2;
float c = 0.0;
c = (float)a/b;
printf("%.1f", c);
return 0;
  

%.1f returns with one decimal place %.2f with two houses and etccc

    
01.06.2018 / 01:20