Thread: Keeping the fractional part of a quotient

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    16

    Keeping the fractional part of a quotient

    I am working on a lab problem. It is: Write a program that calculates the speed of sound (a) in air of a given temperature T (in Fahrenheit). The formula to compute the speed in feet/second:
    a = 1086 * sqrt ((5T+297)/247)
    Be sure your program does not lose the fractional part of the quotient in the formula shown. As part of your solution, write and call a function that displays instructions to the program user.

    I know how to do everything else but keep the fractional part. Below is my program. If anyone could help me out with this I'd really appreciate it. In another problem from this lab we used the scale function to round a number so I'm not sure if we might need to use this function again?

    Code:
    #include <stdio.h>
    #include <math.h>
    
    int main (void)
    {
    	float sound, temperature;
    	printf("Enter a temperature T in fahrenheit: ");
    	scanf("%f", &temperature);
    
    	sound = 1086 * (sqrt ((5 * temperature + 297) / 247));
    
    	printf("When the temperature is %f F, the speed of sound in the air is %f\n", temperature, sound);
    	return 0;
    }
    Last edited by Salem; 03-17-2011 at 07:26 AM. Reason: Added [code][/code] tags

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suspicious Pointer Conversion
    By mr_spanky202 in forum C Programming
    Replies: 35
    Last Post: 04-11-2003, 12:35 PM
  2. RichEdit, how to centralise the focused part?
    By Zahl in forum Windows Programming
    Replies: 1
    Last Post: 11-25-2002, 03:35 PM
  3. Beginning MFC (Prosise) Part III - Now What? :: C++
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 03-03-2002, 06:58 PM
  4. keeping track of # of files
    By blind_collision in forum C Programming
    Replies: 1
    Last Post: 10-13-2001, 09:10 AM