Source code display: Source code is a Fahrenheit to Celsius temperature of the program.
#include <stdio.h>
//void Fahr_Celsius()
int main()
{
//int fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
printf("Hello world!\n");
int fahr, celsius;
fahr = lower;
while (fahr<=upper)
{
celsius = 5 * (fahr - 32)/9;
printf("%d\t%d\n", fahr, celsius);
fahr = fahr + step;
}
return 0;
}
2. Cause of the problem
In C, all variables must be declared before they are used. Declarations are usually placed at the beginning, before any executable statement. Declare the properties used to describe variables, which consist of a type name and a variable scale.
Here because the variable declaration statement on line 12 is placed after the executable statement.
3. Problem solving
Place all variable declarations before all executable statements. The modified code is as follows:
#include <stdio.h>
int main()
{
int fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
printf("Hello world!\n");
//int fahr, celsius;
fahr = lower;
while (fahr<=upper)
{
celsius = 5 * (fahr - 32)/9;
printf("%d\t%d\n", fahr, celsius);
fahr = fahr + step;
}
return 0;
}
4. Problem summary
Although this problem is a stipulation of C language, it mainly appears in the compilation stage, which is interpreted by the compiler. This problem will not appear in VS2017, but will appear in VS2010.
Read More:
- error: a label can only be part of a statement and a declaration is not a statement (How to Fix)
- The language of C__ FILE__ 、__ LINE__ And line
- Vs debug window flashback
- C / C + + library function (tower / tower) realizes the conversion of letter case
- Error c2143: syntax error: missing ‘;’ before ‘type’
- Error in comparing the size function of STL with negative number
- Explain stdin, stdout, stderr in C language
- Gcc compiler warning solution: “extra tokens at end of ifndef directive” Tags: GCC, warning
- C + + pauses the black window system (“pause”); (get ch(), getchar(), system (pause)’s connection and difference
- C + + uses system (“pause”) to pause black windows
- Successfully resolved error c3861: ‘printf’: identifier not found
- Two lines of code to solve your vs flashback problem
- Errno in Linux Programming
- Solutions to error c2143: syntax error: missing ‘;’ before ‘type’ in C + + program compilation
- pthread_ Introduction and application of join function
- Error c2137 of C language: empty character constant (Fixed)
- The function and usage of argc and argv in C language
- Environment configuration at the beginning of OpenCV + vs2015
- Python UnboundLocalError: local variable ‘num’ referenced before assignment
- Flashback problem of output window of visual studio 2017 console program