Submitted by Anonymous (not verified) on Sun, 03/10/2013 - 00:26

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson. The answers and hints to the questions and exercises are given in Appendix E, "Answers to Quiz Questions and Exercises."
Quiz

    What does the following statement do?

    int array_int[4] = {12, 23, 9, 56};

    Given an array, int data[3], what's wrong with the following initialization?

    data[1] = 1;
    data[2] = 2;
    data[3] = 3;

    How many dimensions do the following arrays have?
        char array1[3][19];
        int array2[];
        float array3[][8][16];
        char array4[][80];
    What's wrong with the following declaration?

    char list_ch[][] = {
             `A', `a',
             `B', `b',
             `C', `c',
             `D', `d',
             `E', `e'};

Exercises

    Given this character array:

    char array_ch[5] = {`A', `B', `C', `D', `E'};

    write a program to display each element of the array on the screen.
    Rewrite the program in exercise 1, but this time use a for loop to initialize the character array with `a', `b', `c', `d', and `e', and then print out the value of each element in the array.
    Given this two-dimensional unsized array:

    char list_ch[][2] = {
             `1', `a',
             `2', `b',
             `3', `c',
             `4', `d',
             `5', `e',
             `6', `f'};

    write a program to measure the total bytes taken by the array, and then print out all elements of the array.
    Rewrite the program in Listing 12.5. This time put a string of characters, I like C!, on the screen.
    Given the following array:

    double list_data[6] = {
             1.12345,
             2.12345,
             3.12345,
             4.12345,
             5.12345};

    use the two equivalent ways taught in this lesson to measure the total memory space taken by the array, and then display the results on the screen.

Related Items

মডুলার C প্রোগ্রামিং (Modular C Programming)

কেবল মাত্র একটি ফাংশন দিয়ে কোনো বড়ো জটিল সমস্যা সমাধানের চেষ্টা করা ভাল প্রোগ্রামিংয়ের পদ্ধতি নয়। সঠিক পদ্ধতি হ'ল সমস্যাটিকে কয়েকটি ছোট ছোট এবং সরল টুকরো করে ফেলা যাতে তা আরও বিশদে বোঝা যায় । তারপরে এই ছোট এবং সরল সমস্যাগুলি সমাধান করার জন্য ছোট ছোট ফাংশন ব্লক তৈরি করা এবং পরে সেগুলি নিয়মানুযায়ী সংযোজিত করা ।

Programming Style

Programming Style

In this section, I'd like to briefly highlight some points that will help you write clean programs that can easily be read, understood, and maintained.

Exercises : Answer the following Question

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

Question and Answer

    Q Is the C preprocessor part of the C compiler?

    A No. The C preprocessor is not part of the C compiler. With its own line-oriented grammar and syntax, the C preprocessor runs before the compiler in order to handle named constants, macros, and inclusion of files.

Compiling Your Code Under Conditions

Compiling Your Code Under Conditions

You can select portions of your C program that you want to compile by using a set of preprocessor directives. This is useful, especially when you're testing a piece of new code or debugging a portion of code.