CO 101 CO 102
Introductory Computing Computing Lab.
Instructor : Siddhartha S. Satapathy, Dr. Utpal Sharma and Bidyut Kr. Patra, Dept. CSE.
01/18/11
Objectives
To give basic programming skills. To give conceptual understanding of computers and their working. At the end of the course the student is expected to write a moderately complex C program.
01/18/11
Text books
ANSI C - Programming Language --Kernighan and Richie Mastering C -- Venugopal and Prasad You may follow any other standard ANSI C book.
01/18/11
Lab. Part
Use only Linux Operating System. [ Do not use Microsoft windows ! ] Use ANSI C (Standard C). Use vi editor for creating your files. A brief about the 1st exercise will be given towards the end of this class.
01/18/11
Introduction: Computer
A device basically meant to do computations. A machine that can follow a sequence of instructions. Parts which physically does the execution are called Hardware. The sequence of steps (instructions) can be called as Software.
01/18/11
Hardware and Software
Hardware: Software: OS: Keyboard, Mouse, Monitor, Printer, CPU, Memory, etc. Set of programs, like
Interface between hardware & user. Translates from high level language to machine Language.
Compiler:
Tools: Internet access, Voice, Video, Games, etc.
01/18/11
Computer (Conceptually)
01/18/11
An Example
Work to be done: Buy 1 kg Alu. Sequence of Steps:
1. 2. 3. 4. 5. 6.
Take Bag, Money. Go to Market. Search for good Alu. Buy 1kg Alu. Go home. Stop.
01/18/11
A Model ( Human)
01/18/11
Body Hardware Thinking Process (Mind) Software
9
Early Computers
Fixed-program computer: Can do specific task(s) which is wired (fixed) into the hardware. E.g.: A Calculator. Drawback: No flexibility Stored-program computer: By creating an instruction set architecture and detailing the computation as a series of instructions (the program), the machine becomes much more flexible.
10
01/18/11
Stored-Program Computers
Program is also seen as data. Program is also stored in memory as data. The ability to treat instructions as data is what makes assemblers, compilers and other automated programming tools possible. One can write programs which write programs
01/18/11
11
Von Neumann Architecture
01/18/11
12
Are there other architectures?
Harvard architecture Stores program in a separate memory and data in a separate memory. But, these are rarely used in general purpose computers.
01/18/11
13
What you have to do?
Learn basic commands to work with the linux operating system. Learn vi editor. (This is a software tool which is used to create files).
01/18/11
14
Your first lab exercise
Create a file named first.c whose contents should be:
#include<stdio.h> int main( ) { int a, b; printf(Enter an integer value for variable a:); scanf(%d, &a); printf(Enter an integer value for variable b:); scanf(%d, &b); printf(a+b = %d\n, a+b); return 0; }
This will find sum of two integers. Extend this to find their difference, product and division.
01/18/11 15
Linux commands
After you create the file whose name is first.c you need to compile this file to get executable file. At the command prompt do
$ cc first.c
If the compilation is successful this gives a file called a.out
$ ./a.out
The above command executes it.
16
01/18/11
Homework
Learn basic Linux commands and vi editor
Read some book on C language and understand first.c
01/18/11
17