Ubuntu pastebin

Paste.ubuntu.com/p/fVgF72VtZ…

A screenshot of the unary quadratic equation program shared on Ubuntu Pastebin is shown below.

C language programming knowledge

1.CPU memory module hard disk display card motherboard display relationship 2.HelloWord program how to run 3. What is a data type 4. What is a variable 5. Why must a variable be initialized 6. How to define variables 7. What is a base (and the conversion between bases) 8. The representation of constants in C 9. Code normalization 10. Bytes 11. Assigning values to each other between different types of data * 12

Run the HelloWorld

The contents of printf are equivalent to text, but only text can not be run, so after writing the program, it will form a file that can be run. Exe, after the file is generated, the system will request the CPU to execute. In addition, all programs run on the CPU. In the process of explanation, the teacher relies on the following procedures to explain.

What is a data type

I made a mind map to illustrate (in order to prove that the name does not exist, I attached the production map)

variable

The essence of a variable: it is a storage space in memory. The advantage of using a variable is that it is convenient to store data. Variable initialization = variable assigned. !!!!! Variables that are output in the unassigned state are garbage. Garbage values: The output values vary depending on the processor, but are generally fixed. The system will fill in values starting with -8 and ending with 6

How to define variables

Data type (space) Variable name = assignment is equivalent to data type (space) variable name variable name = assignment

#include <stdio.h>
int main (void)
{
int i=3; < = >int i;
             i=3;
printf ("%d",i);
return 0;
}
Copy the code

Into the system

Binary is two into one. Octal is one for every eight. The decimal system is one into ten. Hexadecimal means every hexadecimal.

Conversion between bases

I show it in pictures for clarity. (D: decimal, B: binary, H: hexadecimal, O: octal)

Symbols for writing bases in printf: %d: decimal, % O: octal, %x: hexadecimal (preferably written as %#x or %#x)

Constant representation method in C language

Integer %d: decimal, % O: octal, %x: hexadecimal (preferably written as %#x or %#x) floating point number

  1. Traditional writing: float=3.2\

Float =3.2e2 character single character in quotes eg: ‘A’ correct ‘AB’ error ‘A’ correct string in double quotes ‘A’ correct

The way integers are stored in a computer

Integers are converted to binary code in complement form and stored in the computer real numbers are converted to binary code in IEEEE754 standard and the characters are the same as integers

Standardization of code

Purpose: Make code more maneuverable. Make programs less error-prone Note: symbols and the like should be written in pairs. Code belonging to content is indented. Define a variable with a blank line between the operation and the return value.

byte

1 byte =8 bits 1K =1024 bytes 1M= 1024L 1G=1024M\

When buying a computer, the memory is calculated by 1M=1000K

Different types of direct assignment relation (want to learn fine C language must master)

Conversions between int,long int,short int,float,double,char follow certain rules.

What is ASCII code

The teacher uses this program to explain the function and usage of ASCII code

By modifying the above procedure, we know that variables can only be defined once, but can be assigned multiple times. Keep the following in mind

ASCII is not a value, but a rule. ASCII specifies which integer values to represent different characters. It says’ A ‘– 65 ‘B ‘– 66’ A ‘– 97 ‘B ‘–98 ‘0’–48

Output function usage

Four uses of printf

  1. Printf (” string “); \
  2. Printf (” output control character “, output parameter); \
  3. Printf (” Output controller 1, output controller 2…” , output parameter 1, output parameter 2……) ; \
  4. Printf (” non-output control, output control “, output parameter); \

The output functions include

%d,%ld,%c

%f,%lf,%x

The use of X in printf

Input function usage

  1. Scanf (” Input control character “, input parameter);
  2. Scanf (” non-input controller, input controller “, input parameter);

See program for specific functions

If the red line function is not added to the graph, if the customer adds garbage values in the process of use, the output result will be abnormal.

The red line is the non-output control

Homework problems

3.10-4

A. Type: character, meaning: backspace \

B. Type: integer, no meaning C. Type: floating point, no meaning D. Type: integer (hexadecimal), meaning: 170 E decimal. Type: floating point, meaning: decimal 2*10^30\

3.10-6 Integer %d integer %x character % C floating point % LF string % S floating point %f integer %ld Floating point %f 3.10-8 %d,%d %f,%c 3.11-1\

The integer overflow

#include <stdio.h>
int main(void)
{
int i=2147483647;

printf ("%d %d %d",i,i+1,i+2);

return 0;
}

Copy the code

Floating point overflow

#include <stdio.h>
int main(void)
{
float  i=3.4 e38;

printf ("%f %f ",i,i+1);

return 0;
}
Copy the code

Floating point underflow

#include <stdio.h>
int main(void)
{
float  i=3.2 e-38;

printf ("%f %f ",i,i- 1);

return 0;
}

Copy the code

3.11-2

#include <stdio.h>
int main(void)
{
int  i;
scanf ("%d",&i);
printf ("%c ",i);

return 0;
}

Copy the code

4.8-1

#include <stdio.h>
int main(void)
{
    char ming ;
    char xing ;
    printf ("Please enter your name.");scanf ("%s%s",&ming,&xing);
    printf ("%s,%s\n",ming,xing);
    return 0;
}
Copy the code

4.8-4

#include <stdio.h>
int main(void)
{
    char XINGMING ;
    int h;
    printf ("Please enter your name");
    scanf ("%s",&XINGMING);
    printf ("Please enter your height in feet.");
    scanf ("%d",&h);
    printf ("%s,you are %d feet tall",XINGMING,h);
    return 0;
}
Copy the code

4.8-7

#include <stdio.h>
#include <float.h>
int main(void)
{
float FLT_DIG = 1.0/3.0;
double DBL_DIG = 1.0/3.0;
printf ("%6f,%12f,%16f",FLT_DIG,FLT_DIG,FLT_DIG);
printf ("%6lf,%12lf,%16lf",DBL_DIG,DBL_DIG,DBL_DIG,);
return 0;
}
Copy the code