Programs


  1. What is the purpose of #include <stdio.h> ?

  2. What is a source program? An executable?

  3. Is a semi-colon required after a comment?

  4. What is wrong with the following statement?
    printf(Hello World\n);
    
  5. What is wrong with the following statement?
    PRINTF("Hello World\n");
    
  6. What is the purpose of the \n ?

  7. What is wrong with the following statement?
    
    printf("Hello World"\n);
    


Answers


































  1. It includes the header file stdio.h into the source code. This file is required for input and output to the program. Therefore, if the printf statement is used to output text/data to the screen it is required.

  2. Source code is the actual C program which is typed into the file. This is then co mpiled into machine code which can be executed by the computer.

  3. No - a comment is not a program statement, so does not require to be terminated by a semi-colon.

  4. The text to be printed must be within double quotes.
    
    printf("Hello World\n");
    
  5. Keywords in C must be lowercase PRINTF must be written as printf

  6. The \n causes the a new line. It is required at the end of Hello WOrld to ensure the curser returns to the next line.

  7. The \n (newline) is text to be printed and must be within the double quotes.


Back to Questions Back to Main Page for Lecture 1