Calculate the value of their difference divided by their product. - C Operator

C examples for Operator:Arithmetic Operator

Description

Calculate the value of their difference divided by their product.

Demo Code

#include <stdio.h>

float calculate(float n1, float n2);

int main(void)
{
  float num1, num2;
  int reads;//from ww w. j  a va 2s  . co  m
  
  printf("Enter two floating-point numbers: ");
  while (scanf(" %f %f", &num1, &num2) == 2)
  {
    printf("(%.3f - %.3f)/(%.3f * %.3f) = %.3f\n", num1, num2, num1, num2, calculate(num1, num2));
    printf("Enter two floating-point numbers (enter non-numeric to quit): ");
  }

  return 0;
}

float calculate(float n1, float n2){
  return (n1 - n2) / (n1 * n2);
}

Result


Related Tutorials