Function exercise

This is a discussion on Function exercise within the C Programming forums, part of the General Programming Boards category; Hi everyone can anyone help me with this little problem... Write a program that requests two floating-point numbers and prints ...

  1. #1
    Bit
    Bit is offline
    Registered User
    Join Date
    Sep 2004
    Posts
    3

    Question Function exercise

    Hi everyone can anyone help me with this little problem...

    Write a program that requests two floating-point numbers and prints the value of their difference divided by their product.

    I do not understand what is ment by getting their difference or how to get it, can anyone please help me out with a little example(the calculation), please...

  2. #2
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    im not to sure what you mean but as for dividing the 2 numbers here is an example

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    int main(void)
    {
    	float num1 , num2;
    
    	printf("Enter 2 Numbers : ");
    	scanf("%f %f" , &num1 , &num2);
    	printf("%.2f Divided by %.2f is %.2f\n" , num1 , num2 , num1 / num2);
    
    	system("pause");
    
    	return 0;
    }
    [edited]
    also because they are floats it will have the remainder.
    [/edited]

  3. #3
    Registered User manofsteel972's Avatar
    Join Date
    Mar 2004
    Posts
    317
    difference is the values subtracted from each other

    difference between 1 and 5 is 4 (ie 5-1);

    so subract the values save the result as difference;
    multiply the values save the result as product;
    then take difference/product;
    "Knowledge is proud that she knows so much; Wisdom is humble that she knows no more."
    -- Cowper

    Operating Systems=Slackware Linux 9.1,Windows 98/Xp
    Compilers=gcc 3.2.3, Visual C++ 6.0, DevC++(Mingw)

    You may teach a person from now until doom's day, but that person will only know what he learns himself.

    Now I know what doesn't work.

    A problem is understood by solving it, not by pondering it.

    For a bit of humor check out xkcd web comic http://xkcd.com/235/

  4. #4
    Bit
    Bit is offline
    Registered User
    Join Date
    Sep 2004
    Posts
    3
    Thank you...

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Do NOT request people do your homework for you. Read the Announcements. But as they say, it's too late now. Congradulations, you'll go far in life if you can get everyone to do everything for you all the time.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Surprised you don't know what 'difference' means, if you're at a grade level in which there's comp sci...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #7
    Bit
    Bit is offline
    Registered User
    Join Date
    Sep 2004
    Posts
    3
    I was confused about why it is I need to divide the difference by the product and what this would achieve, obviosly it was just an exercise and the output of the program was nothing but an argument passed to a function...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  5. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21