Tuesday, 13 August 2013

Tutorial 1 Introduction to C

Tutorial 1 Introduction to C

1 Categorize each of the following items as either hardware or software:
   a) CPU
   ANS: hardware.
   b) C compiler
   ANS: software.
   c) ALU
   ANS: hardware.
   d) C preprocessor
   ANS: software.
   e) input unit
   ANS: hardware.
   f) a word processor program
   ANS: software.


2 Why might you want to write a program in a machine-independent language instead of a machine-dependent   language?
Why might a machine-dependent language be more appropriate for writing certain types of programs?

ANS: Machine independent languages are useful for writing programs to be executed on multiple computer platforms.
Machine dependent languages are appropriate for writing programs to be executed on a single platform. Machine dependent
languages tend to exploit the efficiencies of a particular machine.


3 Translator programs such as assemblers and compilers convert programs from one language (referred to as the source language)
to another language (referred to as the object language). Determine which of the following statements are true and which are
false:
a) A compiler translates high-level language programs into object language.
ANS: True.
b) An assembler translates source language programs into machine language programs.
ANS: True.
c) A compiler converts source language programs into object language programs.
ANS: False.
d) High-level languages are generally machine-dependent.
ANS: False.
e) A machine language program requires translation before the program can be run on a computer.
ANS: False.



4 Fill in the blanks in each of the following statements:
a) Devices from which users access timesharing computer systems are usually called .
ANS: terminals.
b) A computer program that converts assembly language programs to machine language programs is called .
ANS: an assembler.
c) The logical unit of the computer that receives information from outside the computer for use by the computer is called
ANS: The input unit.
d) The process of instructing the computer to solve specific problems is called .
ANS: computer programming.
e) What type of computer language uses English-like abbreviations for machine language instructions? .
ANS: a high-level language.
f) Which logical unit of the computer sends information that has already been processed by the computer to various devices
so that the information may be used outside the computer? .
ANS: The output unit.
g) The general name for a program that converts programs written in a certain computer language into machine language is.
ANS: compiler.
h) Which logical unit of the computer retains information? .
ANS: memory unit and secondary storage unit.
i) Which logical unit of the computer performs calculations? .
ANS: arithmetic and logical unit.
j) Which logical unit of the computer makes logical decisions? .
ANS: arithmetic and logical unit
k) The commonly used abbreviation for the computer's control unit is .
ANS: CPU.
l) The level of computer language most convenient to the programmer for writing programs quickly and easily is
.
ANS: high-level language.
m) The only language that a computer can directly understand is called that computer's .
ANS: machine language.
n) Which logical unit of the computer coordinates the activities of all the other logical units? .
ANS: central processing unit.



5 State whether each of the following is true or false. If false, explain your answer.
a) Machine languages are generally machine dependent.
ANS: True. Machine languages are closely related to the hardware of a particular machine.
b) Like other high-level languages, C is generally considered to be machine independent.
ANS: True. C programs can be written on most machines, and with some care, C programs can be written on one machine
and run on many machines with few changes or no changes.