?
Solved

Print Mathematical function in C

Posted on 2003-02-23
1
Medium Priority
?
289 Views
Last Modified: 2010-04-15
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
Comment
Question by:gmahler5th
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
tinchos earned 80 total points
ID: 8005466
#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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question