Hi guys, I'm a complete newb to both this site and C in general. I have a homework assignment that is supposed to take temperatures a user inputs (as many as they want) and then display how how they fall into three different categories (hot, moderate, and cold) and the average temperature at the end. I have a good chunk of code done, but I am unsure about how much is too much to post! I would gladly PM it to someone though. any tips are appreciated!!
I am using the SSH secure shell to connect to my college, am and editing the programs with the PICO editor and running them using gcc and a.out.
3 1717 sicarie 4,677
Recognized Expert Moderator Specialist
Well, what is your question? Are you having issues with your code, or do you not know how to implement a certain part?
PS - I'm moving this from the Articles section to the Forum section ;)
oler1s 671
Recognized Expert Contributor
This program shouldn't take too many lines to program. It's small enough that you can post the entire code.
As sicarie said, dumping code here is pointless. We can find code in less than 5 seconds with a google search. You have to give us a question, and some details like, why you think something is wrong, the observations to support that idea, what you tried to fix the problem, why it failed, etc. By giving us the entire story (along with a question), you allow us to help you.
ok, sorry about that guys. I'm trying to add all of the temperatures that the user will input while running the code, but I cannot figure out how to use parameter passing on the variable "input". I got it working on the rest but...
here are the compilation errors:
ghp7.c: In function `main':
ghp7.c:37: error: syntax error before ')' token
ghp7.c: In function `get_and_calc_temps':
ghp7.c:50: warning: comparison between pointer and integer
ghp7.c:53: warning: assignment makes integer from pointer without a cast
ghp7.c:55: error: syntax error before "else"
ghp7.c:58: warning: assignment makes integer from pointer without a cast
ghp7.c:60: error: syntax error before "else"
ghp7.c:63: warning: assignment makes integer from pointer without a cast
and here is the code in its entirety: -
#include<stdio.h> //necessary to use printf and scanf
-
int get_and_calc_temps(int* , int*, int*, int*);//pcf created to obtain and calc user input
-
void display_results(int, int, int);
-
void averager(int,int,int);
-
int main(void) //begin program
-
{
-
int temps=0 ,hot = 0, cold = 0, pleasant = 0, average = 0 ,temperatures = 0, input = 0;
-
//decleare local variables
-
char repeat = 'Y';
-
-
-
printf("\nthis program will calculate the average of a group of user");//greeting
-
printf("temperatures, and will also group them into three categories,");
-
printf("cold, moderate, and hot.\n\n");
-
-
-
-
-
-
while ( ( repeat == 'Y') || ( repeat =='y'))
-
-
{
-
get_and_calc_temps(&hot, &cold, &pleasant, &input);
-
display_results(hot, cold, pleasant);
-
printf("do you want to input any more temperatures? (Y/N): ");
-
scanf(" %c", &repeat*);
-
}
-
display_results(hot,cold,pleasant);
-
return(0);
-
-
}
-
int get_and_calc_temps(int *hot, int *cold, int *pleasant, int *input)
-
//pcf get_and)_calc_temps, obtains and calculates and sorts temperatures
-
{
-
-
printf("please input a temperature: ");
-
scanf("%i", *input);
-
-
if (input < 60)
-
-
*cold = *cold + 1;
-
*input = *input+input;
-
-
else if (input >= 85)
-
-
*hot = *hot + 1;
-
*input = *input+input;
-
-
else if ((input <65) &&(input > 85))
-
-
*pleasant= *pleasant + 1;
-
*input = *input+input;
-
-
return(0);
-
-
-
}
-
void display_results( int hot, int cold, int pleasant)
-
{
-
-
printf("\n%d, %d, %d\n\n", hot, cold, pleasant);
-
return;
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Derek Ross |
last post by:
Hello,
Say I have a server that's saving the CPU temperature to
'temperature.js' once a second. The contents of the file is one single
line:
var temperature = "35.5";
And it changes as...
|
by: deanfamily11 |
last post by:
I'm trying to have this program do a simple temperature conversion from
Fahrenheit to Celsius. I have confirmed that the other variable is
receiving and calculating the conversion, but it is just...
|
by: anthony |
last post by:
One the computer I am programmig I could see the CPU temperature in the
BIOS, is there a system DLL in VB.NET that I can call to display the
temperature in my software?
Thanks!
|
by: FBM |
last post by:
Hi,
I am working on a program that simulates one of the elements of ATM.
The simulation stores events which occurs every some milliseconds for a
certain amount of time. Every time that an event...
|
by: alexandre_irrthum |
last post by:
Hi there,
I am trying to use pyserial to read data from a temperature logger
device (T-logger). T-logger is based on the DS1615 temperature recorder
chip (Dallas Semiconductor). According to the...
| |
by: pollardw |
last post by:
i have written a small program to convert Fahrenheit to Celsius and I have a minor problem. Here is the code what do i need to change to get it to work?
/*
Convert Fahrenheit to Celsius
*/
...
|
by: AsheeG87 |
last post by:
Hey Everyone~
I'm still a C++ Rookie so please bear with me on this.
I'm doing a temperature conversion program with prototype functions.
Basicly, I was wondering if some of you would take a look...
|
by: kid joe |
last post by:
Hi,
Is it normal for the temperature of your CPU to increase as time goes on?
I've got an Athlon XP 2100+ and I see that the temp is now at 51C where it
used to be around 42 to 44.
Anyone...
|
by: lemlimlee |
last post by:
hello,
this is the task i need to do:
For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |