As a beginner, you still want to try and find that it is really similar to C #.
Calculate the average of the three numbers entered. This is also a small example in the book.
Preparations:
Create an empty shell as above and prepare to write code
Knowledge: Remember % F. We have learned C #. If we know float, F is short for float, which indicates that a float or double type value is input here. After the input, the correct data type is saved directly. For the "%" number, there are other formats.
% D integer output, % LD long integer output,
% O outputs integers in octal format,
% X outputs integers in hexadecimal notation,
% U outputs unsigned data in decimal number (unsigned number ).
% C is used to output a character,
% S is used to output a string,
% F is used to output real numbers in decimal form,
% E outputs real numbers in exponential form,
% G automatically selects the F format or eformat based on the size, and does not output meaningless zero.
Then prepare the empty shell
Let's write an AVE method. The returned method is a little different from that of C #. the variables are enclosed in brackets, and the others are the same.
Return to the main function and continue coding.
# Include <stdio. h>
FloatAve (FloatF1,FloatF2,FloatF3 ){
FloatA1;
A1 = (F1 + F2 + F3)/3;
Return(A1 );
}
IntMain (IntArgc,Char* Argv [])
{
FloatX1, x2, X3, X4;
Scanf ("% F, % F, % F", & X1, & X2, & X3 );
X4 = ave (x1, x2, X3 );
Printf ("% F \ n", X4 );
Scanf ("% F");
Return0;
}