WHYYYY??

So I try to display temperatures from 100 down to -273 celsius.
Why are this only showing from 25 to -273????
If I change to lower limit to for example -4, everything is OK.

?????? WHYY????


#include <iostream>;

using namespace std;

int main(){


for (int i=100; i>-274; i--){

cout<< i <<"\n";


}
system("pause");

}
By scrolling down lines, you reach a point where older lines are lost.

Try this:

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>;

int main(){
    for (int i = 100; i > -274; i--)
    {
        std::cout<< i;
        if( (i%2) == 0)
           std::cout << std::endl;
    }
    std::cin.get();
    return 0;
}


This places a newline every two numbers, allowing you to see them all.
Heey thanks! I'm very new to C++ so there's no change I would've figured this out :D
Now I have another problem, which was my main problem:
My task is to find all temperatures that are same in celsius and fahrenheit with accuray of 1 degree. How this code doesnt find them, it doesn't show anything? I'm using the double to int trick so if to temperatures are same within one degree, it makes same integer out of them. For example if we have 1.9 and 1.0 -> both changes to 1 so they are within one degree.


#include <iostream>;

using namespace std;

int main(){
for (int i = 100; i > -274; i--)
{

double celsius=(double) i;
double fahrenheit=32+9/5*i;

int Celsius=(int) celsius;
int Fahrenheit=(int) fahrenheit;

if(Celsius==Fahrenheit)
{
cout<<Celsius<<"\n";
}
}
cin.get();
return 0;
}
because 9/5 is an integer division which is always 1. change it like so:

double fahrenheit=32+9.0/5*i; // Note that .0 makes a floating point operation
Whether you use Celsius or Fahrenheit as your unit of measurement, any given liquid will freeze at the same point on a graph and boil at another point. The upshot is that there will only ever be a single point on your graph where the two different scales meet, hence one numeric value in both Celsius and Fahrenheit that is the same.

The formulae to convert C to F =>

F = C * 9 / 5 + 32

F to C =>

C = (F - 32)* 5 / 9

So the formulae to find the point at which they both meet is:

Answer = -32 * 5/4

=> -40
Last edited on
TY!
Topic archived. No new replies allowed.