How to use C language Mathematical Formula to express Love
This article mainly introduces how to use C language mathematical formula to express love, the article is very detailed, has a certain reference value, interested friends must read it!
First, briefly introduce the knowledge points that need to be used and the usage of each knowledge point
(1) output function: printf (); (printf ()) is the C language standard library function, which is used to output the formatted string to standard output. )
Its usage is as follows:
The # include// library function / / defines the usage of the main function int main () {printf ("HelloWorld!\ n"); / * the output function printf, where\ n is an escaped character and is used for line breaks. * / return 0ram / program end flag}
The result of the compilation is as follows:
(2) Macro definition: # define (in C language, you can use # define to define an identifier to represent a constant. Its characteristic is that the defined identifier does not occupy memory, but is only a temporary symbol, which does not exist after precompilation. )
Its usage is as follows:
# include// library function # define PAI 3.1415 / / here we macroscopically define the value of the identifier PAI as 3.1415 / / define the main function int main () {printf ("% f", PAI); / * output the value of PAI, where% f is the format control of PAI to ensure the accuracy of the numbers it outputs * / return 0 position / program end flag}
The result of the compilation is as follows:
(3) input function: scanf (); (for the program to get the data you enter from the keyboard and assign values to the variables defined in the program)
Its usage is as follows:
# include// library function / / define the main function int main () {int a / define an integer variable a scanf ("% d", & a); / * any value of a from the keyboard, because both the definition and% d control the int type, so the input value should be the integer * / printf ("a% d", a); / / the value of the integer output an is return 0 / / Program end flag}
The result of the compilation is as follows:
Ps: what I input from the keyboard is 3, that is, I assign a value of 3 to a, so I output axi3.
(4) floating point definition: float (one of the four types, used to define more precise numbers, ranging from-3.402823466 × 10 to the 38th power of 3.402823466 × 10)
Its usage is as follows:
# include// library function / / define the main function int main () {float aplink 3.134122 / define an as a single-precision floating-point number printf ("aplf", a); / / the value of the single-precision output an is return 0ram / program end flag}
The result of the compilation is as follows:
(5) Mathematical formula: ((Xuan 10402628) * 10-X*10) / 20; (where X is any two numbers, but the resulting value of the formula will be 5201314)
-that's all the knowledge above, basic and simple.
2. Finally, let's go to the program # include / / header file # define JZZ 10402628 / * macro to define the value of JZZ. Here we give you a small tip, that is, JZZ can be changed to any letter, you know what I mean? * / int main () / main function {float fNumber; / / define a variable float fResult1 / / because the formula is too long, the following is divided into two calculations, so define two result values float fResult2; / / assign the final result value to the variable printf ("Please enter a number:\ n"); / / output the prompt word and wrap scanf ("% f", & fNumber); / / assign the input value to the defined variable fNumber fResult1= (fNumber+JZZ) * 10-fNumber*10 / * the input number is brought into the formula and calculated, in which the macro definition JZZ is used, which represents the above 10402628 * / fResult2=fResult1/20; / / assigns the final result value 5201314 to fResult2 printf ("whatever you enter I want to say to you:% f\ n", fResult2); / / output statement and result value return 0; / / end of the program}
The result of the compilation is as follows:
The above is all the contents of the article "how to use C language mathematical formula to express your love". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!