Convert temperature from Celsius degrees into Fahrenheit - C++ Data Type

C++ examples for Data Type:int

Introduction

Formula to convert temperature from Celsius degrees into Fahrenheit

Fahrenheit = Celsius  * (212 - 32)/100 + 32

Demo Code

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    int celsius;/*  ww w  . jav  a2 s  . c  o m*/
    cout << "Enter the temperature in Celsius:";
    cin >> celsius;

    int factor;
    factor = 212 - 32;

    int fahrenheit;
    fahrenheit = factor * celsius/100 + 32;

    cout << "Fahrenheit value is:";
    cout << fahrenheit << endl;

    return 0;
}

Result


Related Tutorials