Ok today Im gonna to show you,How to make simple Temperature Conversion Program using C++,its easy and Pretty nice

here the codes,Now play time 😉

#include <iostream>

int main()

{

int celsius,fahrenheit;

std::cout<<“\nEnter Temperature in Faherenite: “;

std::cin>>fahrenheit;

celsius=5*(fahrenheit-32)/9;

std::cout<<“Temperature is “;

std::cout<<celsius;

std::cout<< ” Degrees celsius”;

std::cout<<“\nEnter Any key to Exit “;

return 0;

}

**celsius=5*(fahrenheit-32)/9;**

if the parentheses were not used initially 5 would be multiplied with the variable fahreheit. Because we want to subtract 32 from fahreheit initially we need to use brackets.

without the parentheses,the multiplication would be carried out first,since * has higher priority than -.with the parentheses are carried out first.

what about the precedence of the * and / signs? when two arithmetic operators have the same precedence,the one on the left is executed first,so the multiplication will be carried out next;then division.precedence and parentheses are normally applied this same way in algebra and other computer languages.so their use probably seems quite natural.however,precedence is an important topic in C++.

### Like this:

Like Loading...

*Related*

## Leave a Reply