Reputation: 1536
I'm trying to change fahrenheit to Kelvin anf the formula is K = 5/9 (° F - 32) + 273
My code is:
#include <stdio.h>
double const changeToC = 32.0;
double const changeToK = 273.16;
void temperatures(double n);
int main(void)
{
int q = 'q';
double userNumber;
printf("please enter fahrenheit number: \n");
scanf("%f", &userNumber);
while (userNumber != q)
{
temperatures(userNumber);
printf("\n");
printf("please enter fahrenheit number: \n");
scanf("%f", &userNumber);
}
}
void temperatures(double n)
{
double celsius, kelvin;
celsius = 5.0 / 9.0 * (n - changeToC);
kelvin = 5.0 / 9.0 (n - changeToC) + changeToK;
printf("fahrenheit is: %.2f - celsius is: %.2f - kelvin is: %.2f",
n, celsius, kelvin);
}
I need the input to get a fahrenheit in double, and print the value of celsius and kelvin.
In the fahrenheit to kelvin(kelvin = 5.0 / 9.0 (n - changeToC) + changeToK;
) line I'm getting an error:
called object type double is not function or function pointer
Can you please tell me what this means?
Upvotes: 5
Views: 2781
Reputation: 2711
kelvin = 5.0 / 9.0 * (n - changeToC) + changeToK;
Place the multiplication operator.. this solves your issue
Upvotes: 0
Reputation: 612884
You missed the multiplication operator, *
kelvin = 5.0 / 9.0 * (n - changeToC) + changeToK;
Without the multiplication operator, the compiler treats the parentheses ()
as the function call operator.
Upvotes: 8