"C-Language Discovery Tour" Part tenth lesson: exercises and assignments

Source: Internet
Author: User

650) this.width=650; "Src=" https://mmbiz.qlogo.cn/mmbiz/ Iahl5mqlicpymsxnmqu4vuqob6yjojt8jqgar6qhickg25ia7exqw0c2ickpf9mhibt1iad0op6vwnhvd8rgpjuoc4sa/0?wx_fmt=jpeg " Style= "Height:auto;" alt= "0?wx_fmt=jpeg"/>


Content Introduction


< Strong style= "padding:0px;margin:0px;" >1

< Strong style= "padding:0px;margin:0px;" >2 < Strong style= "padding:0px;margin:0px;" > < Strong style= "padding:0px;margin:0px;" > exercises and exercises

3, the third part of the first lesson trailer: Install SDL


Course Outline


Our courses are divided into four parts, each of which will be followed by exercises, and the answers will be published. will also bring you in C language to write three games.


Basic knowledge of C language programming


    • What is programming?

    • 工欲善其事, its prerequisite

    • Your first program

    • The world of variables

    • It's a matter of arithmetic.

    • Conditional expressions

    • Looping statements

    • Combat: The first C-language mini-game

    • Function

    • Exercises

    • Exercise: Perfecting the first C-language mini-game


Advanced technology in C language


    • Modular programming

    • Advance pointer, C-language ace

    • Array

    • String

    • Pretreatment

    • Create your own variable type

    • File read/write

    • Dynamic allocation

    • Actual combat: "Hanging villain" game

    • Secure text input

    • Exercises

    • Exercises: Interpreting pointers in your own language


Developing 2D games with the C-based SDL library


    • Installing the SDL

    • Creating Windows and Canvases

    • Display image

    • Event handling

    • Combat: "Super Mary Push Box" game

    • Mastering the use of time

    • Edit text with Sdl_ttf

    • Control sound with Fmod

    • Actual combat: visual voice Spectral lines

    • Exercises


Data


    • Linked list

    • Heap, stack, and queue

    • Hash table

    • Exercises



Part II, lesson 11th: Exercises and Assignments


These exercises are to help you consolidate knowledge, in fact, not difficult, especially for those who have programming experience, but our tutorial is mainly for beginners.

Do not look at the answer to complete these 15 questions, are single-choice.


Exercises


  1. What is a global variable?


    A. Variables that can be accessed anywhere

    B. Variables of variable type arbitrary

    C. Declaring a variable in the main function


  2. When we introduce the header file of the standard library, which of the following ways is used?


    A. #include <time.h>

    B. #include "time.h"

    C. #include {time.h}

    D. #include [time.h]


  3. is C language compiled in the following order? (In fact, there is a step omitted: The assembly (used in the assembler, will not repeat))


    A. Linking with compilation----preprocessing

    B. Preprocessing, compile-and-link

    C. Compile with link-to-preprocessing

    D. Pre-processing, link-to-compile


  4. If I write &toto, what do I get?


    A. Address of Toto

    B. The value of Toto

    C. The value of the variable that toto points to


  5. What values do we use to initialize pointers?


    A. Nothing

    B. 1

    C. NULL

    D. MAIN

    E. 0_address


  6. The code is as follows:


    int number = 8;

    int *pointer = &number;


    Assuming that number is at memory address 5000, and pointer this pointer is at memory address 2500, then what if you print the value of *pointer in the next program?


    A. 5000

    B. 2500

    C. 8

    D. No foreseeable


  7. What is the index of the array from the beginning?


    A. 0

    B. 1

    C.-1


  8. Which line of 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];


  9. The following program has an error, which one?


    int main (int argc, char *argv[])

    {

    Char city[100];

    printf ("Which city do you live in?");

    scanf ("%s", &city);

    printf ("You live in%s, this city is familiar to me!");

    return 0;

    }


    A. Less & in the second printf city

    B. In the definition of the city array, there are fewer * numbers in front of city

    C. & in front of scanf city

  10. Which preprocessing command indicates a #if的结束?


    A. #elif

    B. #endif

    C. #ifdef

    D. #ifndef


  11. Can I include an array inside a struct?


    A. You can

    B. Can not

    C. Yes, but only if the array is of the same type


  12. Why do we usually prefer to use a function to initialize a struct?


    A. Once the structure has been modified, we do not need to redo all initialization of this struct in the program

    B. This is faster for computers

    C. This can turn my code into a C + + form


  13. What should you always do after opening a file?


    A. Closing A file

    B. Testing the validity of a file pointer

    C. Emptying the contents of a file

    D. Place the cursor at the top of the file


  14. What does the following code do?


    malloc (sizeof (int) * 25);


    A. Request a 25-byte int variable in memory

    B. Request an array of type int in memory, array containing 25 elements

    C. Request a 25-byte float variable in memory

    D. Request an array of type float in memory, array containing 25 elements


  15. What is a buffer overflow?


    A. The stored string exceeds the maximum capacity of the buffer

    B. Entering a dead loop when reading a buffer

    C. Memory leaks caused when we lose a pointer to a string



Answers to the exercises


    1. A

    2. A

    3. A

    4. A

    5. C

    6. C

    7. A

    8. C

    9. C

    10. B

    11. A

    12. A

    13. B

    14. B

    15. A



Exercise

Interpreting the pointer in your own language


Always small to say, may be a bit nagging. This time, listen to the officials.


Pointers are the essence of C language, and the reason why C is so flexible and powerful and has pitfalls. If you learn C and do not understand pointers, then you do not have a grasp of the essence.


So in this "exercise", we ask you to use their own language (of course, Chinese ah, you do not give me in English or other languages ...) haha) to explain the pointers and see how well you understand them.


If you don't remember very well, please review our previous lesson on pointers: pointers, the Ace of C language.


Store your explanation in a Word document, or TXT file, or PDF file, and send it to the small box (see below).

Don't be a long-winded one, it would be better to first smooth out some basic concepts of pointers.


I'll get back to you.


Even if you do not send to me, please take a look at pointers to the knowledge point, you can read the "C and Pointers", "c expert programming", "C Language Depth Anatomy" and other books.



The third part of the first lesson notice:


Today's class will come here, together refueling it.

Next time we learn: install SDL


Shenmon

Email: [Email protected]

qq:379641629

: Frogoscar

Work: Embedded Software engineer

Place of residence: south of France

Established "Programmer's Alliance" public Number: Programmerleague

This article is from the "Programmer Alliance Frogoscar" blog, so be sure to keep this source http://4526621.blog.51cto.com/4516621/1680146

"C-Language Discovery Tour" Part tenth lesson: exercises and assignments

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.