473,472 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Temperature Sorting program issues

2 New Member
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.
Oct 20 '07 #1
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 ;)
Oct 20 '07 #2
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.
Oct 20 '07 #3
illusion311
2 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h> //necessary to use printf and scanf
  2. int get_and_calc_temps(int* , int*, int*, int*);//pcf created to obtain and calc user input
  3. void display_results(int, int, int);
  4. void averager(int,int,int);
  5. int main(void) //begin program
  6. {
  7. int temps=0 ,hot  = 0, cold = 0, pleasant = 0, average = 0 ,temperatures = 0, input = 0;
  8.   //decleare local variables
  9. char repeat = 'Y';
  10.  
  11.  
  12. printf("\nthis program will calculate the average of a group of user");//greeting
  13. printf("temperatures, and will also group them into three categories,");
  14. printf("cold, moderate, and hot.\n\n");
  15.  
  16.  
  17.  
  18.  
  19.  
  20. while ( ( repeat == 'Y') || ( repeat =='y'))
  21.  
  22. {
  23. get_and_calc_temps(&hot, &cold, &pleasant, &input);
  24. display_results(hot, cold, pleasant);
  25. printf("do you want to input any more temperatures? (Y/N):  ");
  26. scanf(" %c", &repeat*);
  27. }
  28. display_results(hot,cold,pleasant);
  29. return(0);
  30.  
  31. }
  32. int get_and_calc_temps(int *hot, int *cold, int *pleasant, int *input)  
  33. //pcf get_and)_calc_temps, obtains and calculates and sorts temperatures
  34.  {
  35.  
  36. printf("please input a temperature:  ");
  37.  scanf("%i", *input);
  38.  
  39. if (input < 60)
  40.  
  41. *cold = *cold + 1;
  42. *input = *input+input;
  43.  
  44. else if (input >= 85)
  45.  
  46. *hot = *hot + 1;
  47. *input = *input+input;
  48.  
  49. else if ((input <65) &&(input > 85))
  50.  
  51. *pleasant= *pleasant + 1;
  52. *input = *input+input;
  53.  
  54. return(0);
  55.  
  56.  
  57. }
  58. void display_results( int hot, int cold, int pleasant)
  59. {
  60.  
  61. printf("\n%d, %d, %d\n\n",  hot, cold, pleasant);
  62. return;
  63. }
Oct 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
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...
1
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...
5
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!
4
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...
7
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...
1
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 */ ...
21
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...
25
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...
5
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
1
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...
0
tracyyun
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...
1
isladogs
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.