First of all we need to understand what is called programming. Programming is to display the tasks that you want the computer to do in the form of code, and then compile it into a language that the computer can understand (machine language). The details of programming and computer fundamentals are not repeated here, and can be found in the articles published by the Science Alliance of Shenzhen Middle School.
Install the compiler first, either Visual Studio or Dev-cpp. Bad performance of the computer recommended Dev-cpp, after all, VS has 20GB ...
Not compile code can be private four uncle (+v letter zhengjiayou2002)
Uncle Si will respond to you within 100 working days!
First task: Hello World
It seems that basically all the books in the first chapter will be output HelloWorld.
So I'm directly on the code, you guys feel the C + + language framework
Behind the two slashes is the comment, which is the part that is not read by the computer.
#include <iostream>//introduced header file, not explained here
using namespace std;//defines a namespace, which is not explained here int main ()//main function, the computer will only execute the statement inside { cout<<"helloWorld";//output a text hello World. }
The results of the program output after compiling the run are as follows
Hello World
Second task: Write a a+b calculator
Task fine: Write a program, read two integers a and B, output a+b. ( -1000<a,b<1000)
This is where we need the variables. Variables are a very important component in programming. It takes up a bit of space in your memory strips to store information. Here we use the variable of type int, that is, the variable of integer type. As the name implies, a variable can only store an integer, and the absolute value of the integer is less than or equal to 2^31.
Then our code is as follows:
#include <iostream>using namespacestd;intMain () {intb;//defines two variables. cin>>a>>b;//read two numbers and deposit A and B variables separately intC=a+b;//use C variables to deposit A and B variables andcout<<c;//value of output Ccout<<endl;//outputs a newline character. cout<<a+b;//this is equivalent to defining a C and then outputting. Because cout will define the intermediate variables to calculate the value of a+b. }
The results are as follows:
read in data: 5 5 Program output: Ten Ten
The third task: Judging whether the four-tertiary math pass
Four uncle because the final math exam did not pass, so hard, decided to blow brush deep math test paper. He knows his score. He wants you to help him write a program to judge whether he has passed or not.
We only need a judgment statement:
if (condition) { If the condition is met, the content is executed. }
Else
{
Content that does not meet the conditions that are executed.
}
Code:
#include <iostream>usingnamespace std; int Main () { int A; CIN>>A; if (a>=) { cout<<' passed!!! "; } else { cout<< "failed Qaq";} }
The fourth task is left to the reader to implement itself.
Four uncle because the final math exam did not pass, so hard, decided to blow brush all over the math papers. But the overall scores are different, he knows his score and total, the pass line is 100 points of 60 points. He wants you to help him write a program to judge whether he has passed or not.
Tip: A/b represents the value of a divided by B. If A and B are integer, they are rounded down. The task guarantees that the answer will not be affected after rounding down. (Although all four uncles pass the line in each exam)
The input format is two digits
Score of four tert-scores
Give me a chestnut:
Input:
Max 107
Output:
Pass!!!
A simple tutorial on c++/c language (Shenzhen High School Science Alliance Information Society)