Hey guys im having a bit of trouble compiling my code. I dont know where im going wrong.. Can anyone please help me out?
the error codes im getting are:
Error E2109 lab8.c 68: Not an allowed type in function readType.
Error E2109 lab8.c 71: Not an allowed type in function readType.
Error E2193 lab8.c 82: Too few parameters in call to 'readTemp' in function main.
Error E2193 lab8.c 83: Too few parameters in call to 'readType' in function main.
Code:
#include <stdio.h>
/*
This program is designed to convert kelvin into
fahrenhiet or celsius.
*/
void convertC(int kelvin, int celsius)
{
(celsius = (kelvin - 273));
if(celsius < 1)
{
printf("The water is in a solid state at %d degrees celsius.\n", celsius);
}
else if(celsius > 0 && celsius < 100)
{
printf("The water is in a liquid state at %d degrees celsius.\n", celsius);
}
else
{
printf("The water is in a gas state at %d degrees celsius.\n", celsius);
}
}
void convertF(int fahrenhiet, int celsius, int kelvin)
{
(celsius = (kelvin - 273));
(fahrenhiet = (9 * celsius / 5) + 32);
if(fahrenhiet < 33)
{
printf("The water is in a solid state at %d degrees fahrenhiet.\n", fahrenhiet);
}
else if(fahrenhiet > 32 && fahrenhiet < 212)
{
printf("The water is in a liquid state at %d degrees fahrenhiet.\n", fahrenhiet);
}
else
{
printf("The water is in a gas state at %d degrees fahrenhiet.\n", fahrenhiet);
}
}
void readTemp(int kelvinNumber)
{
int kelvin, *ptr;
char type;
ptr = &kelvin;
printf("Please enter a the sample temperature in Degrees Kelvin:>345\n");
scanf("%d", &kelvin);
if(kelvin <= 345)
{
printf("You did not enter the correct value\n");
exit(0);
}
else
{
printf("You entered %dK\n", *ptr);
}
}
void readType(char type)
{
int kelvin, celsius, fahrenhiet;
printf("Do you wish to convert the temperature to (c) for Celsius, or (f) for Fahrenheit");
getchar();
scanf("%c", &type);
switch(type)
{
case 'c' :
celsius = convertC(kelvin, celsius);
break;
case 'f' :
fahrenhiet = convertF(fahrenhiet, celsius, kelvin);
break;
default:
printf("You did not enter correct letter!");
break;
}
}
int main()
{
printf("Welcome to the temperature conversion program!\n");
readTemp(kelvin);
readType(type);
}