Exercises : Answer these Questions

Submitted by tushar pramanick on Mon, 02/25/2013 - 09:57

Exercises

  1. Given two statements, x = 3; and y = 5 + x;, how can you build a statement block with the two statements?

  2. What is wrong with the following function?

 int 3integer_add( int x, int y, int z)
    {
       int sum;
       sum = x + y + z;
       return sum;
    }  


3. What is wrong with the following function?

    int integer_add( int x, int y, int z)
    {
       int sum;
       sum = x + y + z
       return sum;
    }

 

4. Write a C function that can multiply two integers and return the calculated result.
5. Write a C program that calls the C function you just wrote in exercise 4 to calculate the multiplication of 3 times 5 and then print out the return value from the function on the screen.

 

Workshop

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."

 

কুইজ

  1. In the C language, is 74 a constant? How about 571?
  2. Is x = 570 + 1 an expression? How about x = 12 + y?
  3. Are the following function names valid?

              2methods
              m2_algorithm
              *start_function
              Room_Size
              .End_Exe
              _turbo_add

 

    4. Is 2 + 5 * 2 equal to (2 + 5) * 2?
    5. Does 7 % 2 produce the same result as 4 % 3?

 

Related Items

The #define and #undef Directives

The #define and #undef Directives

The #define directive is the most common preprocessor directive, which tells the preprocessor to replace every occurrence of a particular character string (that is, a macro name) with a specified value (that is, a macro body).

The C Preprocessor Versus the Compiler

The C Preprocessor Versus the Compiler

One important thing you need to remember is that the C preprocessor is not part of the C compiler.

What Is the C Preprocessor?

If there is a constant appearing in several places in your program, it's a good idea to associate a symbolic name to the constant, and then use the symbolic name to replace the constant throughout the program. There are two advantages to doing so. First, your program will be more readable.

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 Why is random access to a disk file necessary?