Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
This is very old code, way before 1998 when C++ became the standard.
Now (but not in the know - in C ++ 98 or C ++ 03), a huge number of C ++ headers have been combined into the standard template library (STL). So the code needs to be slightly modified.
1. Instead <iostream.h>
of using <iostream>
. <stdio.h>
, in principle, works, but it is recommended to take <cstdio>
.
2. All functions are in the namespace std
. That is: std::cout
, std::endl
, etc. Or, as suggested by D' Normalization , using namespace std;
.
1. What is wrong
2. Includes (#include) are empty
3. After the includes should be using namespace std; Or just sign cout and cin with std:: (std::cout, std::cin)
Toaster, what's wrong with you? Stop breaking. Formatted and *working* code (the toaster won't suggest editing):
// Программа для преобразования
// градусов Цельсия в градусы Фаренгейта:
// Fahrenheit = NCelsius * (212 - 32)/100 + 32
//
#include <stdio.h>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// Введите температуру в градусах Цельсия
int nNCelsius;
cout << "Введите температуру по Цельсию: ";
cin >> nNCelsius;
// для приведенной формулы преобразования
//вычислим преобразующий множитель
int nNFactor;
nNFactor = 212 - 32;
// используем вычисленный множитель для
// преобразования градусов Цельсия в
// градусы Фаренгейта
int nFahrenheit;
nFahrenheit = nNFactor * nNCelsius/100 + 32;
// вывод результатов
cout << "Температура по Фаренгейту: ";
cout << nFahrenheit;
return 0;
}
$ g++ 1.cpp
$ ./a.out
Enter Celsius temperature: 22
Fahrenheit temperature: 71
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question