[C language exploration tour] Part 2 Lesson 10: Exercise questions and exercises, study tours
Introduction
1. Course outline
2. Part 2 Lesson 11th: Exercise questions and exercises
3. Part 3 Lesson 1 notice: Install SDL
Course outline
Our courses are divided into four parts. Each part has exercise questions after completion and answers will be published. Three games will also be written in C language.
Basic knowledge of C Programming
What is programming?
To do their best, you must first sharpen your tools.
Your first program
World of Variables
Computing
Conditional expressions
Loop statement
Practice: The first C games
Function
Exercise questions
Exercise: Perfect the first C games
C Advanced Technology
Modular programming
Attack pointer, C trump card
Array
String
Preprocessing
Create your own variable type
File read/write
Dynamic Allocation
Practice: "hanging villain" games
Exercise questions
Exercise: Explain the pointer in your own language
Develop 2D games with C language-based SDL Library
Install SDL
Create a window and canvas
Show images
Event Processing
Practice: "Super Mary pushes boxes" games
Time usage
Use SDL_ttf to edit text
Use FMOD to control sound
Practice: Visual Sound line
Exercise questions
Data Structure
Linked List
Heap, stack, and queue
Hash table
Exercise questions
Part 2 Lesson 1: Exercise questions and exercises
These exercises help you to consolidate your knowledge. In fact, it is not difficult, especially for people with programming experience, but our tutorials are mainly for beginners.
If you don't want to answer these 15 questions, all of them are single-choice questions.
Exercise questions
What is a global variable?
A. variables that can be accessed everywhere
B. Any variable of the variable type
C. Declare the variables in the main function
Which of the following methods is used when we introduce standard library header files?
A. # include <time. h>
B. # include "time. h"
C. # include {time. h}
D. # include [time. h]
C language compilation in the following order? (In fact, one step is omitted here: Assembly (if assembler is used, it will not be repeated ))
A. Preprocessing-> compilation-> Link
B. Compile-> link-> preprocessing
C. Link-> preprocessing-> Compilation
D. Preprocessing-> link-> Compilation
If I write & toto, what do I get?
A. toto address
B. toto Value
C. Value of the variable to which toto points
What value should we use to initialize the pointer?
A. NOTHING
B. 1
C. NULL
D. MAIN
E. 0_ADDRESS
The Code is as follows:
Int number = 8;
Int * pointer = & number;
Suppose the number is at the memory address 5000, And the pointer is at the memory address 2500. What is the value of * pointer printed in the next program?
A.m. 5000
B. 2500
C. 8
D. Unpredictable
How many times does the subscript of an array start?
A. 0
B. 1
C.-1
Which of the following code is used to create an array with 10 double variables?
A. double * array [10];
B. double array {10 };
C. double array [10];
D. double array [9];
Which of the following programs has an error?
Int main (int argc, char * argv [])
{
Char city [100];
Printf ("Which city do you live in? ");
Scanf ("% s", & city );
Printf ("You live in % s. I am very familiar with this city! ", City );
Return 0;
}
A. The city in the second printf is missing &
B. In the definition of the city array, the number * is missing before the city.
C. Add an ampersand before the city in scanf.
Which preprocessing command indicates # End of if?
A. # elif
B. # endif
C. # ifdef
D. # ifndef
Can struct contain arrays?
A. Yes
B. No
C. Yes, but only when the array is of the same type
Why do we usually prefer to use a function to initialize the struct?
A. Once the struct has been modified, we do not need to re-initialize it in the program.
B. This is faster for computers.
C. This can turn my code into a C ++ form.
What should I do after opening a file?
A. close the file
B. test the validity of the file pointer.
C. Clear the File Content
D. Place the cursor at the beginning of the file.
What is the role of the following code?
Malloc (sizeof (int) * 25 );
A. Apply for A 25-byte int variable in the memory.
B. Apply for an int array in the memory. The array contains 25 elements.
C. Apply for a 25-byte float variable in the memory
D. Apply for a float array in the memory. The array contains 25 elements.
What is buffer overflow?
A. the stored string exceeds the maximum buffer capacity.
B. There is an endless loop in the buffer zone.
C. Memory leakage caused by the loss of a pointer to a string
Exercise answer
A
A
A
A
C
C
A
C
C
B
A
A
B
B
A
Exercise
Explanation pointer in your own language
It may be a bit nagging. This is what the audience will talk about.
Pointer is the essence of C language, and it is also the reason why C language is flexible and powerful and has a trap. If you are not familiar with the C language, you cannot grasp the essence.
Therefore, in this exercise, we asked everyone to use their own language (of course, it is Chinese. Please do not use English or other languages for me... haha) Let's explain the pointer and see how everyone understands it.
If you do not know clearly, please review our previous lesson on pointers: "the trump card of pointer and C language".
Store Your explanation in a Word document, TXT file, or PDF file and send it to your mailbox (see below ).
Don't give me a long story. It would be better to explain the basic concepts of some pointers first.
I will reply.
Even if you don't send it to me, please take a look at the pointer knowledge. You can read books such as C and pointer, C expert programming, and C language deep anatomy.
Part 3 Preview of Lesson 1:
Today's class is here. Come on together.
Next learning:Install SDL
Author: Xie enming
Email: enmingx@gmail.com
QQ: 379641629
: Frogoscar
Work: Embedded Software Engineer
Place of residence: south France
Public Account of the [programmer Alliance]: programmerleleague
Copyright Disclaimer: This article is an original article by the blogger. You must specify the source for reprinting. Otherwise, you will be held legally liable.