C-programming autumn 2010


Exercise 1

9.9 9:00-12:00 B119.

  1. Write into a file "Hello, world" program, compile and make a runnable program. Run the program.
    #include <stdio.h>
    
    int main(void)
    {
    printf("Hello, world!\n");
    return 0;
    }
    
  2. In lecture notes there is a situation, where a program consists of modules (eka, toka, main etc.) Write codes in to files and compile them and make a runnable program from object files. Write also a makefile that does the same and try to use it.

  3. What the following codes of C do?
    a)while (*q++ = *p++);
    b)if ((c=fgetc(fileHandle)) == EOF)
    c)for (i=a, j=b; i<=j; i += 2, j += 2)
    
  4. What advantages/disadvantages you can list if the garbage collection is missing from programming language.
  5. Inspect the sample program sample.c. from course book. List those points, that are unclear for you. (You understand better, if you read chapter 2.)

Study also
  1. Compiling, linking and running programs in Linux environment
  2. Evaluation order

.