Thread: A question about convert()

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    3

    A question about convert()

    Hello

    I have to write a program that uses a function called convert(), which prompts hte user for an amount in dollars and returns this value converted into pounds. Exchange rate of 2 dollars per pound.
    This is a exercise from Herbert Shildts book Teach Yourself C.

    I checked the net to find out what and how this function works but I didnt find anything.

    So far I have written:

    Code:
    #include <stdio.h>
    #include <math.h>
    
    void convert(void);
    
    int main(void)
    {
        int dollar;
        
        printf("Enter the value in dollars: ");
        scanf("%d" &dollar);
        convert();
        
        printf("This equals to the following amount of pounds");
        return 0;
    }
    
    void convert()
    {
        
    }

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    I have to write a program that uses a function called convert(), which prompts hte user for an amount in dollars and returns this value converted into pounds.
    So do you know how to do the first part (prompt the user)?

    What about the second part (return a value)?

    You really should also start looking for a better book. Your current book is probably based on one of the worst books on programming (in any computer language) ever written. By the way I say probably because it could be the worst of the worst, the first printing. Avoid all books by that author and find a different book.

  3. #3
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,106
    Quote Originally Posted by GodEmperor View Post
    Hello

    I have to write a program that uses a function called convert(), which prompts hte user for an amount in dollars and returns this value converted into pounds. Exchange rate of 2 dollars per pound.
    This is a exercise from Herbert Shildts book Teach Yourself C.

    I checked the net to find out what and how this function works but I didnt find anything.
    Have you studied the chapter on functions, as well as all the chapters that came before? If so you should have all the information you need to do the exercise.

    If you need a better book on C, can I recommend one of three different books?

    C Programming, A Modern Approach
    Author: K. N. King


    C Primer Plus, 6th Edition
    Stephen Prata


    C How to Program, 8/e
    Deitel & Deitel

    Choose one of the above, study it cover to cover, and do all the exercises at the end of each chapter.

  4. #4
    Registered User
    Join Date
    Dec 2019
    Posts
    3
    So do you know how to do the first part (prompt the user)?
    scanf asks you after you run the program for a value and you type it.

    What about the second part (return a value)?
    I don't know the answer for this question.

    By the way I say probably because it could be the worst of the worst, the first printing. Avoid all books by that author and find a different book.
    It is actually the third edition of Teach Yourself C by Schildt. I'm just curious why does he have such a negative opinion.

  5. #5
    Registered User
    Join Date
    Dec 2019
    Posts
    3
    Quote Originally Posted by rstanley View Post
    Have you studied the chapter on functions, as well as all the chapters that came before? If so you should have all the information you need to do the exercise.

    If you need a better book on C, can I recommend one of three different books?

    C Programming, A Modern Approach
    Author: K. N. King


    C Primer Plus, 6th Edition
    Stephen Prata


    C How to Program, 8/e
    Deitel & Deitel

    Choose one of the above, study it cover to cover, and do all the exercises at the end of each chapter.
    I did all the exercises.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 04-20-2016, 03:13 AM
  2. Replies: 17
    Last Post: 07-26-2012, 09:32 PM
  3. QUESTION: Convert numbers to words
    By amplechin in forum C++ Programming
    Replies: 2
    Last Post: 11-23-2011, 01:15 PM
  4. Convert.ToDouble question
    By antex in forum C# Programming
    Replies: 4
    Last Post: 05-16-2006, 11:13 AM
  5. Easy convert question
    By bcianfrocca in forum C++ Programming
    Replies: 7
    Last Post: 09-09-2005, 07:55 AM

Tags for this Thread