intro slides 3

115
Introduction Title page CS11001/CS11002 Programming and Data Structures Autumn/Spring Semesters Introduction Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Last modified: July 8, 2010

Upload: muhammed-razi

Post on 29-Nov-2014

54 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Intro Slides 3

Introduction

Title page

CS11001/CS11002 Programming and Data StructuresAutumn/Spring Semesters

Introduction

Department of Computer Science & EngineeringIndian Institute of Technology, Kharagpur

Last modified: July 8, 2010

Page 2: Intro Slides 3

Introduction

Syllabus

Syllabus

Introduction to digital computersBasic programming constructs

Variables and simple data typesAssignmentsInput/outputConditions and branchingLoops and iterationIterative searching and sorting algorithms

Advanced programming constructsFunctions and recursionRecursive sorting algorithmsArrays and stringsStructuresPointers and dynamic memory allocation

Page 3: Intro Slides 3

Introduction

Syllabus

Syllabus

Introduction to digital computers

Basic programming constructsVariables and simple data typesAssignmentsInput/outputConditions and branchingLoops and iterationIterative searching and sorting algorithms

Advanced programming constructsFunctions and recursionRecursive sorting algorithmsArrays and stringsStructuresPointers and dynamic memory allocation

Page 4: Intro Slides 3

Introduction

Syllabus

Syllabus

Introduction to digital computersBasic programming constructs

Variables and simple data typesAssignmentsInput/outputConditions and branchingLoops and iterationIterative searching and sorting algorithms

Advanced programming constructsFunctions and recursionRecursive sorting algorithmsArrays and stringsStructuresPointers and dynamic memory allocation

Page 5: Intro Slides 3

Introduction

Syllabus

Syllabus

Introduction to digital computersBasic programming constructs

Variables and simple data typesAssignmentsInput/outputConditions and branchingLoops and iterationIterative searching and sorting algorithms

Advanced programming constructsFunctions and recursionRecursive sorting algorithmsArrays and stringsStructuresPointers and dynamic memory allocation

Page 6: Intro Slides 3

Introduction

Syllabus

Syllabus (contd.)

Performance analysis of programsData structures

Abstract data typesOrdered listsStacks and queues

Programming language: C

Page 7: Intro Slides 3

Introduction

Syllabus

Syllabus (contd.)

Performance analysis of programs

Data structuresAbstract data typesOrdered listsStacks and queues

Programming language: C

Page 8: Intro Slides 3

Introduction

Syllabus

Syllabus (contd.)

Performance analysis of programsData structures

Abstract data typesOrdered listsStacks and queues

Programming language: C

Page 9: Intro Slides 3

Introduction

Syllabus

Syllabus (contd.)

Performance analysis of programsData structures

Abstract data typesOrdered listsStacks and queues

Programming language: C

Page 10: Intro Slides 3

Introduction

References

On C

Textbooks and references

Use any standard textbook on ANSI C

Do not use books written on specific C compilers (Turbo C, gcc)

1 Brian W. Kernighan and Dennis M. Ritchie, The CProgramming Language, Prentice Hall of India.

2 E. Balaguruswamy, Programming in ANSI C, TataMcGraw-Hill.

3 Byron Gottfried, Schaum’s Outline of Programming with C,McGraw-Hill.

4 P. Dey and M. Ghosh, Programming in C, Oxford UniversityPress.

Page 11: Intro Slides 3

Introduction

References

On C

Textbooks and references

Use any standard textbook on ANSI C

Do not use books written on specific C compilers (Turbo C, gcc)

1 Brian W. Kernighan and Dennis M. Ritchie, The CProgramming Language, Prentice Hall of India.

2 E. Balaguruswamy, Programming in ANSI C, TataMcGraw-Hill.

3 Byron Gottfried, Schaum’s Outline of Programming with C,McGraw-Hill.

4 P. Dey and M. Ghosh, Programming in C, Oxford UniversityPress.

Page 12: Intro Slides 3

Introduction

References

On C

Textbooks and references

Use any standard textbook on ANSI C

Do not use books written on specific C compilers (Turbo C, gcc)

1 Brian W. Kernighan and Dennis M. Ritchie, The CProgramming Language, Prentice Hall of India.

2 E. Balaguruswamy, Programming in ANSI C, TataMcGraw-Hill.

3 Byron Gottfried, Schaum’s Outline of Programming with C,McGraw-Hill.

4 P. Dey and M. Ghosh, Programming in C, Oxford UniversityPress.

Page 13: Intro Slides 3

Introduction

References

On C

Textbooks and references

Use any standard textbook on ANSI C

Do not use books written on specific C compilers (Turbo C, gcc)

1 Brian W. Kernighan and Dennis M. Ritchie, The CProgramming Language, Prentice Hall of India.

2 E. Balaguruswamy, Programming in ANSI C, TataMcGraw-Hill.

3 Byron Gottfried, Schaum’s Outline of Programming with C,McGraw-Hill.

4 P. Dey and M. Ghosh, Programming in C, Oxford UniversityPress.

Page 14: Intro Slides 3

Introduction

References

On data structures

Textbooks and references

5 Seymour Lipschutz, Data Structures, Schaum’s OutlinesSeries, Tata McGraw-Hill.

6 Ellis Horowitz, Satraj Sahni and Susan Anderson-Freed,Fundamentals of Data Structures in C, W. H. Freeman andCompany.

7 R. G. Dromey, How to Solve it by Computer, Prentice-Hallof India.

8 http://cse.iitkgp.ac.in/∼pds/notes/9 http://cse.iitkgp.ac.in/∼pds/notes/swf/

Page 15: Intro Slides 3

Introduction

References

On data structures

Textbooks and references

5 Seymour Lipschutz, Data Structures, Schaum’s OutlinesSeries, Tata McGraw-Hill.

6 Ellis Horowitz, Satraj Sahni and Susan Anderson-Freed,Fundamentals of Data Structures in C, W. H. Freeman andCompany.

7 R. G. Dromey, How to Solve it by Computer, Prentice-Hallof India.

8 http://cse.iitkgp.ac.in/∼pds/notes/9 http://cse.iitkgp.ac.in/∼pds/notes/swf/

Page 16: Intro Slides 3

Introduction

References

On data structures

Textbooks and references

5 Seymour Lipschutz, Data Structures, Schaum’s OutlinesSeries, Tata McGraw-Hill.

6 Ellis Horowitz, Satraj Sahni and Susan Anderson-Freed,Fundamentals of Data Structures in C, W. H. Freeman andCompany.

7 R. G. Dromey, How to Solve it by Computer, Prentice-Hallof India.

8 http://cse.iitkgp.ac.in/∼pds/notes/9 http://cse.iitkgp.ac.in/∼pds/notes/swf/

Page 17: Intro Slides 3

Introduction

Marks distribution

Marks distribution

Two class tests: 10× 2 = 20Mid-semester test: 30End-semester test: 50

Final marks of a student: M = m × α, where

m = Total marks obtained in 100, andα = Classes attended / Total number of classes.

Page 18: Intro Slides 3

Introduction

Marks distribution

Marks distribution

Two class tests: 10× 2 = 20

Mid-semester test: 30End-semester test: 50

Final marks of a student: M = m × α, where

m = Total marks obtained in 100, andα = Classes attended / Total number of classes.

Page 19: Intro Slides 3

Introduction

Marks distribution

Marks distribution

Two class tests: 10× 2 = 20Mid-semester test: 30

End-semester test: 50

Final marks of a student: M = m × α, where

m = Total marks obtained in 100, andα = Classes attended / Total number of classes.

Page 20: Intro Slides 3

Introduction

Marks distribution

Marks distribution

Two class tests: 10× 2 = 20Mid-semester test: 30End-semester test: 50

Final marks of a student: M = m × α, where

m = Total marks obtained in 100, andα = Classes attended / Total number of classes.

Page 21: Intro Slides 3

Introduction

Marks distribution

Marks distribution

Two class tests: 10× 2 = 20Mid-semester test: 30End-semester test: 50

Final marks of a student: M = m × α, where

m = Total marks obtained in 100, andα = Classes attended / Total number of classes.

Page 22: Intro Slides 3

Introduction

Marks distribution

Marks distribution

Two class tests: 10× 2 = 20Mid-semester test: 30End-semester test: 50

Final marks of a student: M = m × α, where

m = Total marks obtained in 100, and

α = Classes attended / Total number of classes.

Page 23: Intro Slides 3

Introduction

Marks distribution

Marks distribution

Two class tests: 10× 2 = 20Mid-semester test: 30End-semester test: 50

Final marks of a student: M = m × α, where

m = Total marks obtained in 100, andα = Classes attended / Total number of classes.

Page 24: Intro Slides 3

Introduction

Test schedule (tentative)

Tentative schedule of theory tests

Class Test 1: First week of September/February

Mid-semester Test: As per institute schedule

Class Test 2: First week of November/April

End-Semester Test: As per institute schedule

Two or three lab tests are conducted by respective lab instructors

Page 25: Intro Slides 3

Introduction

Test schedule (tentative)

Tentative schedule of theory tests

Class Test 1: First week of September/February

Mid-semester Test: As per institute schedule

Class Test 2: First week of November/April

End-Semester Test: As per institute schedule

Two or three lab tests are conducted by respective lab instructors

Page 26: Intro Slides 3

Introduction

Test schedule (tentative)

Tentative schedule of theory tests

Class Test 1: First week of September/February

Mid-semester Test: As per institute schedule

Class Test 2: First week of November/April

End-Semester Test: As per institute schedule

Two or three lab tests are conducted by respective lab instructors

Page 27: Intro Slides 3

Introduction

Test schedule (tentative)

Tentative schedule of theory tests

Class Test 1: First week of September/February

Mid-semester Test: As per institute schedule

Class Test 2: First week of November/April

End-Semester Test: As per institute schedule

Two or three lab tests are conducted by respective lab instructors

Page 28: Intro Slides 3

Introduction

Test schedule (tentative)

Tentative schedule of theory tests

Class Test 1: First week of September/February

Mid-semester Test: As per institute schedule

Class Test 2: First week of November/April

End-Semester Test: As per institute schedule

Two or three lab tests are conducted by respective lab instructors

Page 29: Intro Slides 3

Introduction

Test schedule (tentative)

Tentative schedule of theory tests

Class Test 1: First week of September/February

Mid-semester Test: As per institute schedule

Class Test 2: First week of November/April

End-Semester Test: As per institute schedule

Two or three lab tests are conducted by respective lab instructors

Page 30: Intro Slides 3

Introduction

Coverage schedule

Tentative schedule for coverage

Before Class Test 1: Until “iterations” (all loop constructs)

Before MidSem Test: Until “introduction to pointers”

Before Class Test 2: Until “linked structures”

Before EndSem Test: Everything

Page 31: Intro Slides 3

Introduction

Coverage schedule

Tentative schedule for coverage

Before Class Test 1: Until “iterations” (all loop constructs)

Before MidSem Test: Until “introduction to pointers”

Before Class Test 2: Until “linked structures”

Before EndSem Test: Everything

Page 32: Intro Slides 3

Introduction

Coverage schedule

Tentative schedule for coverage

Before Class Test 1: Until “iterations” (all loop constructs)

Before MidSem Test: Until “introduction to pointers”

Before Class Test 2: Until “linked structures”

Before EndSem Test: Everything

Page 33: Intro Slides 3

Introduction

Coverage schedule

Tentative schedule for coverage

Before Class Test 1: Until “iterations” (all loop constructs)

Before MidSem Test: Until “introduction to pointers”

Before Class Test 2: Until “linked structures”

Before EndSem Test: Everything

Page 34: Intro Slides 3

Introduction

Coverage schedule

Tentative schedule for coverage

Before Class Test 1: Until “iterations” (all loop constructs)

Before MidSem Test: Until “introduction to pointers”

Before Class Test 2: Until “linked structures”

Before EndSem Test: Everything

Page 35: Intro Slides 3

Introduction

Structure of a C program

How to write C programs

Skeleton of a C program

Include header files

Declare global variables, constants and function prototypes

Function bodies

There must be a main function in any C program.

Page 36: Intro Slides 3

Introduction

Structure of a C program

How to write C programs

Skeleton of a C programInclude header files

Declare global variables, constants and function prototypes

Function bodies

There must be a main function in any C program.

Page 37: Intro Slides 3

Introduction

Structure of a C program

How to write C programs

Skeleton of a C programInclude header files

Declare global variables, constants and function prototypes

Function bodies

There must be a main function in any C program.

Page 38: Intro Slides 3

Introduction

Structure of a C program

How to write C programs

Skeleton of a C programInclude header files

Declare global variables, constants and function prototypes

Function bodies

There must be a main function in any C program.

Page 39: Intro Slides 3

Introduction

Structure of a C program

How to write C programs

Skeleton of a C programInclude header files

Declare global variables, constants and function prototypes

Function bodies

There must be a main function in any C program.

Page 40: Intro Slides 3

Introduction

Structure of a C program

An example

A complete example

#include <stdio.h>

#define PI_4_BY_3 4.1887902048

double radius = 10;

double sphereVol ( double r ){

return PI_4_BY_3 * r * r * r;}

main (){

double area;area = sphereVol(radius);printf("Radius = %lf, volume = %lf.\n", radius, area);

}

Page 41: Intro Slides 3

Introduction

Some simple C programs

The traditional starter

The traditional starter

#include <stdio.h>

main (){

printf("Hello, world!\n");}

This program takes no input, but outputs the string“Hello, world!”

in a line.

Page 42: Intro Slides 3

Introduction

Some simple C programs

The traditional starter

The traditional starter

#include <stdio.h>

main (){

printf("Hello, world!\n");}

This program takes no input, but outputs the string“Hello, world!”

in a line.

Page 43: Intro Slides 3

Introduction

Some simple C programs

The short-circuit program

The short-circuit program

#include <stdio.h>

main (){

int n;

scanf("%d",&n);printf("%d\n",n);

}

This program accepts an integer as input and outputs the sameinteger.

Page 44: Intro Slides 3

Introduction

Some simple C programs

The short-circuit program

The short-circuit program

#include <stdio.h>

main (){

int n;

scanf("%d",&n);printf("%d\n",n);

}

This program accepts an integer as input and outputs the sameinteger.

Page 45: Intro Slides 3

Introduction

Some simple C programs

The square finder

The square finder

#include <stdio.h>

main (){

int n;

scanf("%d",&n);printf("%d\n",n*n);

}

This program takes an integer n as input and outputs thesquare n2 of n.

Page 46: Intro Slides 3

Introduction

Some simple C programs

The square finder

The square finder

#include <stdio.h>

main (){

int n;

scanf("%d",&n);printf("%d\n",n*n);

}

This program takes an integer n as input and outputs thesquare n2 of n.

Page 47: Intro Slides 3

Introduction

Some simple C programs

A faulty reciprocal finder

A faulty reciprocal finder

#include <stdio.h>

main (){

int n;

scanf("%d",&n);printf("%d\n",1/n);

}

The division 1/n is of integers (quotient).

The format %d is for printing integers.

Page 48: Intro Slides 3

Introduction

Some simple C programs

A faulty reciprocal finder

A faulty reciprocal finder

#include <stdio.h>

main (){

int n;

scanf("%d",&n);printf("%d\n",1/n);

}

The division 1/n is of integers (quotient).

The format %d is for printing integers.

Page 49: Intro Slides 3

Introduction

Some simple C programs

A faulty reciprocal finder

A faulty reciprocal finder

#include <stdio.h>

main (){

int n;

scanf("%d",&n);printf("%d\n",1/n);

}

The division 1/n is of integers (quotient).

The format %d is for printing integers.

Page 50: Intro Slides 3

Introduction

Some simple C programs

The correct reciprocal finder

The correct reciprocal finder

#include <stdio.h>

main (){

int n;

scanf("%d",&n);printf("%f\n",1.0/n);

}

Page 51: Intro Slides 3

Introduction

PDS laboratory

PDS Laboratory

Page 52: Intro Slides 3

Introduction

PDS laboratory

Log in

Getting started

Switch on your monitor.Switch on your PC.Allow the machine to boot. Wait until the log in promptcomes.Supply your log-in and password:

Login: s<nn>

Password: s<nn>

Here s is your section (a for 1, b for 2, and so on)<nn> is the number of your PC.

This opens your window manager (usually KDE) withicons, the bottom panel, and so on. You are now ready tostart your work.

Page 53: Intro Slides 3

Introduction

PDS laboratory

Log in

Getting started

Switch on your monitor.

Switch on your PC.Allow the machine to boot. Wait until the log in promptcomes.Supply your log-in and password:

Login: s<nn>

Password: s<nn>

Here s is your section (a for 1, b for 2, and so on)<nn> is the number of your PC.

This opens your window manager (usually KDE) withicons, the bottom panel, and so on. You are now ready tostart your work.

Page 54: Intro Slides 3

Introduction

PDS laboratory

Log in

Getting started

Switch on your monitor.Switch on your PC.

Allow the machine to boot. Wait until the log in promptcomes.Supply your log-in and password:

Login: s<nn>

Password: s<nn>

Here s is your section (a for 1, b for 2, and so on)<nn> is the number of your PC.

This opens your window manager (usually KDE) withicons, the bottom panel, and so on. You are now ready tostart your work.

Page 55: Intro Slides 3

Introduction

PDS laboratory

Log in

Getting started

Switch on your monitor.Switch on your PC.Allow the machine to boot. Wait until the log in promptcomes.

Supply your log-in and password:Login: s<nn>

Password: s<nn>

Here s is your section (a for 1, b for 2, and so on)<nn> is the number of your PC.

This opens your window manager (usually KDE) withicons, the bottom panel, and so on. You are now ready tostart your work.

Page 56: Intro Slides 3

Introduction

PDS laboratory

Log in

Getting started

Switch on your monitor.Switch on your PC.Allow the machine to boot. Wait until the log in promptcomes.Supply your log-in and password:

Login: s<nn>

Password: s<nn>

Here s is your section (a for 1, b for 2, and so on)<nn> is the number of your PC.

This opens your window manager (usually KDE) withicons, the bottom panel, and so on. You are now ready tostart your work.

Page 57: Intro Slides 3

Introduction

PDS laboratory

Edit, compile and run

Getting started

Click on the terminal icon to open a shell (commandprompt).Edit your program (new or already existing) by an editor.

emacs myprog.c &

Write your program in the editor and save it.Go to the shell and compile your program:

cc myprog.c

If compilation is successful, an executable called a.out

will be created.Run your program:

./a.out

Continue your edit-compile-debug-run-debug cycle.

Page 58: Intro Slides 3

Introduction

PDS laboratory

Edit, compile and run

Getting started

Click on the terminal icon to open a shell (commandprompt).

Edit your program (new or already existing) by an editor.emacs myprog.c &

Write your program in the editor and save it.Go to the shell and compile your program:

cc myprog.c

If compilation is successful, an executable called a.out

will be created.Run your program:

./a.out

Continue your edit-compile-debug-run-debug cycle.

Page 59: Intro Slides 3

Introduction

PDS laboratory

Edit, compile and run

Getting started

Click on the terminal icon to open a shell (commandprompt).Edit your program (new or already existing) by an editor.

emacs myprog.c &

Write your program in the editor and save it.Go to the shell and compile your program:

cc myprog.c

If compilation is successful, an executable called a.out

will be created.Run your program:

./a.out

Continue your edit-compile-debug-run-debug cycle.

Page 60: Intro Slides 3

Introduction

PDS laboratory

Edit, compile and run

Getting started

Click on the terminal icon to open a shell (commandprompt).Edit your program (new or already existing) by an editor.

emacs myprog.c &

Write your program in the editor and save it.

Go to the shell and compile your program:cc myprog.c

If compilation is successful, an executable called a.out

will be created.Run your program:

./a.out

Continue your edit-compile-debug-run-debug cycle.

Page 61: Intro Slides 3

Introduction

PDS laboratory

Edit, compile and run

Getting started

Click on the terminal icon to open a shell (commandprompt).Edit your program (new or already existing) by an editor.

emacs myprog.c &

Write your program in the editor and save it.Go to the shell and compile your program:

cc myprog.c

If compilation is successful, an executable called a.out

will be created.

Run your program:./a.out

Continue your edit-compile-debug-run-debug cycle.

Page 62: Intro Slides 3

Introduction

PDS laboratory

Edit, compile and run

Getting started

Click on the terminal icon to open a shell (commandprompt).Edit your program (new or already existing) by an editor.

emacs myprog.c &

Write your program in the editor and save it.Go to the shell and compile your program:

cc myprog.c

If compilation is successful, an executable called a.out

will be created.Run your program:

./a.out

Continue your edit-compile-debug-run-debug cycle.

Page 63: Intro Slides 3

Introduction

PDS laboratory

Edit, compile and run

Getting started

Click on the terminal icon to open a shell (commandprompt).Edit your program (new or already existing) by an editor.

emacs myprog.c &

Write your program in the editor and save it.Go to the shell and compile your program:

cc myprog.c

If compilation is successful, an executable called a.out

will be created.Run your program:

./a.out

Continue your edit-compile-debug-run-debug cycle.

Page 64: Intro Slides 3

Introduction

PDS laboratory

Shut down

Getting started

Close all the windows you opened.Log out from your window manager. This leaves you againin the log-in console.Select the item to shut down the machine. Wait until themachine completely shuts down.Switch off your monitor.

Page 65: Intro Slides 3

Introduction

PDS laboratory

Shut down

Getting started

Close all the windows you opened.

Log out from your window manager. This leaves you againin the log-in console.Select the item to shut down the machine. Wait until themachine completely shuts down.Switch off your monitor.

Page 66: Intro Slides 3

Introduction

PDS laboratory

Shut down

Getting started

Close all the windows you opened.Log out from your window manager. This leaves you againin the log-in console.

Select the item to shut down the machine. Wait until themachine completely shuts down.Switch off your monitor.

Page 67: Intro Slides 3

Introduction

PDS laboratory

Shut down

Getting started

Close all the windows you opened.Log out from your window manager. This leaves you againin the log-in console.Select the item to shut down the machine. Wait until themachine completely shuts down.

Switch off your monitor.

Page 68: Intro Slides 3

Introduction

PDS laboratory

Shut down

Getting started

Close all the windows you opened.Log out from your window manager. This leaves you againin the log-in console.Select the item to shut down the machine. Wait until themachine completely shuts down.Switch off your monitor.

Page 69: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 70: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.

Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 71: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 72: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text area

Navigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 73: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keys

Save your file before closing emacs.“File -> Save (Current buffer)”Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 74: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 75: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”

Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 76: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”Click the save button (disk)

“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 77: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 78: Intro Slides 3

Introduction

PDS laboratory

Using emacs

Using emacs

emacs is a powerful text editor.Run emacs as: emacs myprog.c &

Type in your program in the text areaNavigate with mouse and cursor keysSave your file before closing emacs.

“File -> Save (Current buffer)”Click the save button (disk)“File -> Save buffer as” (to another file)

Save your file once in every 15 minutes.

Page 79: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 80: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.

Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 81: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 82: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matter

You will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 83: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert mode

Hit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 84: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert mode

When in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 85: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view mode

Navigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 86: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keys

You need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 87: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).

Save your file once in every 15 minutes.

Page 88: Intro Slides 3

Introduction

PDS laboratory

Using gvim

Using gvim

gvim is another powerful text editor.Run gvim as: gvim myprog.c

Hit Insert before you start typing matterYou will exit the insert mode if you hit Insert when you arealready in the insert modeHit Esc to exit insert modeWhen in doubt, it is safe to hit Esc several times to comeback to view modeNavigate with mouse and cursor keysYou need to save the file by clicking on the appropriateicon (disk).Save your file once in every 15 minutes.

Page 89: Intro Slides 3

Introduction

PDS laboratory

A practice program

A practice program

#include <stdio.h>

char name[100];int i;

main (){

printf("Hello, may I know your full name? ");scanf("%s",name);printf("Welcome %s.\n",name);printf("Your name printed backward is : ");for (i=strlen(name)-1; i>=0; --i)

printf("%c",name[i]);printf("\n");

}

Page 90: Intro Slides 3

Introduction

PDS laboratory

A corrected version

A practice program (corrected)

#include <stdio.h>

char name[100];int i;

main (){

printf("Hello, may I know your full name? ");fgets(name,100,stdin);name[strlen(name)-1] = ’\0’;printf("Welcome %s.\n",name);printf("Your name printed backward is : ");for (i=strlen(name)-1; i>=0; --i)

printf("%c",name[i]);printf("\n");

}

Page 91: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.Set a proxy:

10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.Type in a URL (web address) in the location field

http://cse.iitkgp.ac.in/∼pds/http://cse.iitkgp.ac.in/∼pds/semester/2010a/http://cse.iitkgp.ac.in/∼pds/notes/

Page 92: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.

Set a proxy:10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.Type in a URL (web address) in the location field

http://cse.iitkgp.ac.in/∼pds/http://cse.iitkgp.ac.in/∼pds/semester/2010a/http://cse.iitkgp.ac.in/∼pds/notes/

Page 93: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.Set a proxy:

10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.Type in a URL (web address) in the location field

http://cse.iitkgp.ac.in/∼pds/http://cse.iitkgp.ac.in/∼pds/semester/2010a/http://cse.iitkgp.ac.in/∼pds/notes/

Page 94: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.Set a proxy:

10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.Type in a URL (web address) in the location field

http://cse.iitkgp.ac.in/∼pds/http://cse.iitkgp.ac.in/∼pds/semester/2010a/http://cse.iitkgp.ac.in/∼pds/notes/

Page 95: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.Set a proxy:

10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.

Type in a URL (web address) in the location fieldhttp://cse.iitkgp.ac.in/∼pds/http://cse.iitkgp.ac.in/∼pds/semester/2010a/http://cse.iitkgp.ac.in/∼pds/notes/

Page 96: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.Set a proxy:

10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.Type in a URL (web address) in the location field

http://cse.iitkgp.ac.in/∼pds/http://cse.iitkgp.ac.in/∼pds/semester/2010a/http://cse.iitkgp.ac.in/∼pds/notes/

Page 97: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.Set a proxy:

10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.Type in a URL (web address) in the location field

http://cse.iitkgp.ac.in/∼pds/

http://cse.iitkgp.ac.in/∼pds/semester/2010a/http://cse.iitkgp.ac.in/∼pds/notes/

Page 98: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.Set a proxy:

10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.Type in a URL (web address) in the location field

http://cse.iitkgp.ac.in/∼pds/http://cse.iitkgp.ac.in/∼pds/semester/2010a/

http://cse.iitkgp.ac.in/∼pds/notes/

Page 99: Intro Slides 3

Introduction

PDS laboratory

Using a web browser

Using a web browser

Open a web browser: mozilla or konqueror.Set a proxy:

10.3.100.211:808010.3.100.212:8080144.16.192.218:8080144.16.192.245:8080144.16.192.247:8080

Bypass proxy for local machines.Type in a URL (web address) in the location field

http://cse.iitkgp.ac.in/∼pds/http://cse.iitkgp.ac.in/∼pds/semester/2010a/http://cse.iitkgp.ac.in/∼pds/notes/

Page 100: Intro Slides 3

Introduction

PDS laboratory

Assignments and submissions

Assignments and submissions

Click the link on the day’s assignment.If your assignment is a PDF file, save it to your machine.Use xpdf in order to view PDF files.

xpdf newassgn.pdf

Consult your lab instructor to know how to submit yourprograms.

Page 101: Intro Slides 3

Introduction

PDS laboratory

Assignments and submissions

Assignments and submissions

Click the link on the day’s assignment.

If your assignment is a PDF file, save it to your machine.Use xpdf in order to view PDF files.

xpdf newassgn.pdf

Consult your lab instructor to know how to submit yourprograms.

Page 102: Intro Slides 3

Introduction

PDS laboratory

Assignments and submissions

Assignments and submissions

Click the link on the day’s assignment.If your assignment is a PDF file, save it to your machine.

Use xpdf in order to view PDF files.xpdf newassgn.pdf

Consult your lab instructor to know how to submit yourprograms.

Page 103: Intro Slides 3

Introduction

PDS laboratory

Assignments and submissions

Assignments and submissions

Click the link on the day’s assignment.If your assignment is a PDF file, save it to your machine.Use xpdf in order to view PDF files.

xpdf newassgn.pdf

Consult your lab instructor to know how to submit yourprograms.

Page 104: Intro Slides 3

Introduction

PDS laboratory

Assignments and submissions

Assignments and submissions

Click the link on the day’s assignment.If your assignment is a PDF file, save it to your machine.Use xpdf in order to view PDF files.

xpdf newassgn.pdf

Consult your lab instructor to know how to submit yourprograms.

Page 105: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 106: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 107: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 108: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 109: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 110: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 111: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 112: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 113: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 114: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename

Page 115: Intro Slides 3

Introduction

PDS laboratory

Some useful Unix commands

Some useful Unix commands

Create a directory: mkdir progs

Go to a new directory: cd progs/

Go to the parent directory: cd ../

List all files in a directory: ls -lF

View a file: cat filename

Copy a file to another: cp file1.c file2.c

Copy a file to a directory: cp file1.c progs/file3.c

Move a file to another: mv file1.c file2.c

Move a file to a directory: mv file1.c progs/file3.c

Delete a file: rm filename