Hey guys, I'm just trying to write a basic program for my first week in a uni course. It's a continuation course of learning about OOP but whereas last semester we were mainly just learning Java and some OOP ideas such as encapsulation, etc. The course this semester covers a little bit about C++ but is mostly about data structures.
The program compiles and run fine in the cygwin terminal but the problem I am having is that when the program enters the for loop, it enters an infinite loop displaying "Celsius: 10 Fahrenheit: 42" but I can't see why.
Sorry if the answer is blindingly obvious but any help is greatly appreciated, cheers.
/*
* Cale Banfield c3132281 06/08/2014
*
* This program takes a lower limit and an upper limit temperature in celsius and then converts them to fahrenheit while displaying
* temperatures in between determined by a value entered by the user.
*
*/
#include <iostream>
usingnamespace std;
int main(){
double lowerLimit, upperLimit, /* Values input by the user for the lower and upper limit temperatures */
celsius, fahrenheit; /* Stores the value of both temperatures Celsius and Fahrenheit */
int step; /* This is the value in which the temperature will be incremented by when it is displayed */
cout << "Enter the lower limit of temperature: ";
cin >> lowerLimit;
cout << "Enter the upper limit of temperature: ";
cin >> upperLimit;
cout << "Enter the step that the temperature will be incremented by: ";
cin >> step;
for (celsius = lowerLimit; celsius < upperLimit; celsius + step) { /* This loop starts from the lower limit and prints the celsius temperature and then */
/* the fahrenheit temperature, incremented by the step until it reaches the upper limit */
fahrenheit = (9 / 5) * celsius + 32;
cout << "Celsius: " << celsius << " " << "Fahrenheit: " << fahrenheit << "\n";
}
return 0;
}
main.cpp:28:59: warning: expression result unused [-Wunused-value]
for (celsius = lowerLimit; celsius < upperLimit; celsius + step) { /* This loop starts from the lower limit and prints the celsius temperature and then */
~~~~~~~ ^ ~~~~