C language Error C2143:syntax error:missing '; ' Before ' type '

Source: Internet
Author: User
1. Description of the problemThe problem shows as shown in the picture: All Ides are VS2010.
Source code: Source code is a program that converts Fahrenheit temperature to Celsius.
#include <stdio.h>

//void fahr_celsius ()
int main ()
{
	//int Fahr, Celsius;
	int lower, upper, step;
	lower = 0;
	upper =;
	Step =;
	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. Problem reason in C language, all variables must be declared before use. A declaration is usually placed at the beginning, before any executable statement. Declares a property that describes a variable, consisting of a type name and a variable table. This is because the variable declaration statement on line 12th is placed after the executable statement. 3. Problem solvingPut all the 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 =;
	Step =;
	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. Summary of Issues

Although this question is the C language stipulation, but this question mainly appears in the compile phase, by the compiler explanation, in VS2017 is not likely to appear this problem, but in VS2010 can appear this kind of problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.