Hi,

So I'm new to C and I'm trying to get the max temp from my user input and the print out in a table the temperature's from 0 to max temp in celsius and fahrenheit. However I can't seem to get the maxtemp from my getinput function. I was wondering if anybody can tell me where I went wrong.
Thanks!

#include <stdio.h>
#include <math.h>

float convertFtoC(float i)
{
	float c;
	c = ((5/9) * (i -32));
	return c;
}

float getinput(float maxtemp)
{
		printf("Enter the max temperature :");
		scanf("%f", &maxtemp);
		if (maxtemp <= 0)
		{
			printf("ERROR! You must enter a positive integer value.\n");
			return 1;
		}
}

int main () 
{
	float i, j;
	float maxtemp;
	maxtemp = getinput(maxtemp);
	for (i = 0; i <= maxtemp; i = i + 5) {
		j = convertFtoC(i);
		printf(" \nTemperature in F\n %f\t Temperature in C \n %f", i, j);
	}
	return 0;
}

You're not returning maxtemp from the getinput function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.