|
Comment LinesDate: 2015-10-07; view: 716. Main( ) { float à,b,ñ,d, average; printf("Enter three numbers:"); scanf ("%f %f, %f ,&a, &b, &c); d=a+b+c; average = d/3. 0; printf(“The average is %f”, average); } À Ñ source program consists of statements and comment lines. Comment lines are enclosed by the characters /* (at the start of thå comment) and */ (at the end of the comment). The Function main{ } Every Ñ program must have a function called mainwhich must àððeàr only once in a program. The parentheses following the word mainmust bå present, but there must be no parentheses included. The main part of the program is enclosed within braces { }, and consists declaration statements, assignment statements, and other Ñ functions. In the above program there are six statements within the braces: à declaration statement (the first statement of the main program starting with the word float),two assignment statements (the fourth and fifth statements starting with the variable names dand average),and three function statements, two to print information on the screen and one to scan the keyboard for input. As Ñ is à free form language, the semicolon (;) at the end of each line is à must. It acts as à statement terminator, telling the compiler where an instruction ends. Free form means that statements can be identified and blank lines inserted in the source file to improve readability, and statements can span several lines. However, each statement must be terminated with à semicolon. If you forget to include the semicolon, the compiler will produce an error, indicating the next line as the source of the error. This can cause some confusion, as the statement objected to can be correct, yet as à syntax error is produced.
|