• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

Print Mathematical function in C

I have the following variables declared, and I need to print an expression which devides 1 by the exchange rate of the local currency.  How do I properly write the mathematical expression using printf?  Essentially, I'm trying to pring "1 Euro = (1/0.932543)" but using the result of the mathematical function.  Thanks!

#include <studio.h>
   main()
   {
      float Euro, Peso, Yen, Pound, Shekel;
      Euro = 0.932543;
      Peso = 10.9554;
      Yen = 118.411;
      Pound = 0.734113;
      Shekel = 4.87100;
   
     
      printf("1 Euro = 1.07234 USD  \n");
      printf("1 Peso = 1.07234 USD  \n");
      printf("1 Yen = 1.07234 USD  \n");
      printf("1 Pound = 1.07234 USD  \n");
      printf("1 Shekel = 1.07234 USD  \n");
      return 0;
   }
0
gmahler5th
Asked:
gmahler5th
1 Solution
 
tinchosCommented:
#include <studio.h>
  main()
  {
     float Euro, Peso, Yen, Pound, Shekel;
     Euro = 0.932543;
     Peso = 10.9554;
     Yen = 118.411;
     Pound = 0.734113;
     Shekel = 4.87100;
   
     
     printf("1 Euro = %f USD  \n", (float)1/Euro);
     printf("1 Peso = %f USD  \n", (float)1/Peso);
     printf("1 Yen = %f USD  \n", (float)1/Yen);
     printf("1 Pound = %f USD  \n", (float)1/Pound);
     printf("1 Shekel = %f USD  \n", (float)1/Shekel);
     return 0;
  }
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now