Temperature coverter problem

In this problem we are required to convert the table of temperature given in fahrenheit to celcius, the video tutorial shows the implementation using while loop. And I tried to implement the question using for loop and my loop is running infinitely.

hello @shazanahmed1
please save ur code on cb ide and share the link with me


here is the link

@shazanahmed1

a) dont hardcode the value.
take input as mentioned in the input format->
image

and then use these values in ur loop instead of ur own.

refer this->

No i’m not talking about the exercise problem in the hackerblocks , this code is from the video tutorial in which the table is given already for both fahrenheit and celcius. And the instructor solve the problem using while loop and I tried the same problem using for loop and I’m getting Infinite running loop by using the for loop.

Instructor’s code :

My Code :

#include
using namespace std;
int main() {
int f;
int c;
for (f=0;f<=300;f+20)
{
c=(5*(f-32))/9;
cout<<f<<" "<<c<<endl;
}
return 0;
}

ok no issue,

here 3rd argument should be f=f+20

1 Like