Basic C programming tutorial
Transcript of Basic C programming tutorial
![Page 1: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/1.jpg)
Introduction
Title page
CS11002 Programming and Data StructuresSpring 2008
Introduction
Goutam BiswasAbhijit Das
Dipankar Sarkar
Department of Computer Science & EngineeringIndian Institute of Technology, Kharagpur
Jan 04, 2008
![Page 2: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/2.jpg)
Introduction
Syllabus
Syllabus
![Page 3: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/3.jpg)
Introduction
Syllabus
Syllabus
Introduction to digital computers
![Page 4: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/4.jpg)
Introduction
Syllabus
Syllabus
Introduction to digital computersBasic programming constructs
Variables and simple data typesAssignmentsInput/outputConditions and branchingLoops and iterationIterative searching and sorting algorithms
![Page 5: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/5.jpg)
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: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/6.jpg)
Introduction
Syllabus
Syllabus (contd.)
![Page 7: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/7.jpg)
Introduction
Syllabus
Syllabus (contd.)
Performance analysis of programs
![Page 8: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/8.jpg)
Introduction
Syllabus
Syllabus (contd.)
Performance analysis of programsData structures
Abstract data typesOrdered listsStacks and queues
![Page 9: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/9.jpg)
Introduction
Syllabus
Syllabus (contd.)
Performance analysis of programsData structures
Abstract data typesOrdered listsStacks and queues
Programming language: C
![Page 10: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/10.jpg)
Introduction
References
On C
Textbooks and references
![Page 11: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/11.jpg)
Introduction
References
On C
Textbooks and references
Use any standard textbook on ANSI C
![Page 12: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/12.jpg)
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)
![Page 13: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/13.jpg)
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: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/14.jpg)
Introduction
References
On data structures
Textbooks and references
![Page 15: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/15.jpg)
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.
![Page 16: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/16.jpg)
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://www.facweb.iitkgp.ernet.in/∼pds/notes/
![Page 17: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/17.jpg)
Introduction
Marks distribution
Marks distribution
![Page 18: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/18.jpg)
Introduction
Marks distribution
Marks distribution
Two class tests: 10 × 2 = 20
![Page 19: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/19.jpg)
Introduction
Marks distribution
Marks distribution
Two class tests: 10 × 2 = 20
Mid-semester test: 30
![Page 20: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/20.jpg)
Introduction
Marks distribution
Marks distribution
Two class tests: 10 × 2 = 20
Mid-semester test: 30
End-semester test: 50
![Page 21: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/21.jpg)
Introduction
Marks distribution
Marks distribution
Two class tests: 10 × 2 = 20
Mid-semester test: 30
End-semester test: 50
Final marks of a student: M = m × α, where
![Page 22: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/22.jpg)
Introduction
Marks distribution
Marks distribution
Two class tests: 10 × 2 = 20
Mid-semester test: 30
End-semester test: 50
Final marks of a student: M = m × α, where
m = Total marks obtained in 100, and
![Page 23: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/23.jpg)
Introduction
Marks distribution
Marks distribution
Two class tests: 10 × 2 = 20
Mid-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 24: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/24.jpg)
Introduction
Test schedule
Tentative schedule of theory tests
![Page 25: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/25.jpg)
Introduction
Test schedule
Tentative schedule of theory tests
Class Test 1: February 06, 2008 (Wednesday)
![Page 26: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/26.jpg)
Introduction
Test schedule
Tentative schedule of theory tests
Class Test 1: February 06, 2008 (Wednesday)
Mid-semester Test: February 22–29, 2008 (Friday to Friday)
![Page 27: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/27.jpg)
Introduction
Test schedule
Tentative schedule of theory tests
Class Test 1: February 06, 2008 (Wednesday)
Mid-semester Test: February 22–29, 2008 (Friday to Friday)
Class Test 2: April 02, 2008 (Wednesday)
![Page 28: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/28.jpg)
Introduction
Test schedule
Tentative schedule of theory tests
Class Test 1: February 06, 2008 (Wednesday)
Mid-semester Test: February 22–29, 2008 (Friday to Friday)
Class Test 2: April 02, 2008 (Wednesday)
End-Semester Test: April 21–29, 2008 (Monday to Tuesday)
![Page 29: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/29.jpg)
Introduction
Lab schedule
Tentative schedule for the laboratory
![Page 30: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/30.jpg)
Introduction
Lab schedule
Tentative schedule for the laboratory
Lab test 1: February 15–21, 2008 (Friday to Thursday)
![Page 31: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/31.jpg)
Introduction
Lab schedule
Tentative schedule for the laboratory
Lab test 1: February 15–21, 2008 (Friday to Thursday)
Lab Test 2: April 04–10, 2008 (Friday to Thursday)
![Page 32: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/32.jpg)
Introduction
Lab schedule
Tentative schedule for the laboratory
Lab test 1: February 15–21, 2008 (Friday to Thursday)
Lab Test 2: April 04–10, 2008 (Friday to Thursday)
Marks distributionLab Test 1: 25Lab Test 2: 35Daily Performance: 40
![Page 33: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/33.jpg)
Introduction
Coverage schedule
Tentative schedule for coverage
![Page 34: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/34.jpg)
Introduction
Coverage schedule
Tentative schedule for coverage
Before Class Test 1: Until “iterations” (all loop constructs)
![Page 35: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/35.jpg)
Introduction
Coverage schedule
Tentative schedule for coverage
Before Class Test 1: Until “iterations” (all loop constructs)
Before MidSem Test: Until “introduction to pointers”
![Page 36: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/36.jpg)
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”
![Page 37: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/37.jpg)
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 38: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/38.jpg)
Introduction
Contacts
Contacts
![Page 39: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/39.jpg)
Introduction
Contacts
Contacts
Instructors
![Page 40: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/40.jpg)
Introduction
Contacts
Contacts
InstructorsSections 1,2: Goutam Biswas, CSE-207, [email protected]://www.facweb.iitkgp.ernet.in/∼goutam/
![Page 41: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/41.jpg)
Introduction
Contacts
Contacts
InstructorsSections 1,2: Goutam Biswas, CSE-207, [email protected]://www.facweb.iitkgp.ernet.in/∼goutam/
Sections 3,4: Abhijit Das, CSE-123, [email protected]://www.cse-web.iitkgp.ernet.in/∼abhij/
![Page 42: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/42.jpg)
Introduction
Contacts
Contacts
InstructorsSections 1,2: Goutam Biswas, CSE-207, [email protected]://www.facweb.iitkgp.ernet.in/∼goutam/
Sections 3,4: Abhijit Das, CSE-123, [email protected]://www.cse-web.iitkgp.ernet.in/∼abhij/
Sections 5,6: Dipankar Sarkar, CSE-115, [email protected]://www.facweb.iitkgp.ernet.in/∼ds/
![Page 43: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/43.jpg)
Introduction
Contacts
Contacts
InstructorsSections 1,2: Goutam Biswas, CSE-207, [email protected]://www.facweb.iitkgp.ernet.in/∼goutam/
Sections 3,4: Abhijit Das, CSE-123, [email protected]://www.cse-web.iitkgp.ernet.in/∼abhij/
Sections 5,6: Dipankar Sarkar, CSE-115, [email protected]://www.facweb.iitkgp.ernet.in/∼ds/
Course web-page:http://www.facweb.iitkgp.ernet.in/∼pds/
http://www.facweb.iitkgp.ernet.in/∼pds/notes/
![Page 44: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/44.jpg)
Introduction
Structure of a C program
How to write C programs
Skeleton of a C program
![Page 45: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/45.jpg)
Introduction
Structure of a C program
How to write C programs
Skeleton of a C program
Include header files
![Page 46: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/46.jpg)
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
![Page 47: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/47.jpg)
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
![Page 48: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/48.jpg)
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 49: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/49.jpg)
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 50: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/50.jpg)
Introduction
Some simple C programs
The traditional starter
The traditional starter
#include <stdio.h>
main (){
printf("Hello, world!\n");}
![Page 51: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/51.jpg)
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 52: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/52.jpg)
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);
}
![Page 53: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/53.jpg)
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 54: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/54.jpg)
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);
}
![Page 55: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/55.jpg)
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 56: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/56.jpg)
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);
}
![Page 57: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/57.jpg)
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).
![Page 58: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/58.jpg)
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 59: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/59.jpg)
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 60: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/60.jpg)
Introduction
PDS laboratory
Log in
Getting started
![Page 61: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/61.jpg)
Introduction
PDS laboratory
Log in
Getting started
Switch on your monitor .
![Page 62: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/62.jpg)
Introduction
PDS laboratory
Log in
Getting started
Switch on your monitor .
Switch on your PC.
![Page 63: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/63.jpg)
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.
![Page 64: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/64.jpg)
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 65: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/65.jpg)
Introduction
PDS laboratory
Edit, compile and run
Getting started
![Page 66: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/66.jpg)
Introduction
PDS laboratory
Edit, compile and run
Getting started
Click on the terminal icon to open a shell (commandprompt).
![Page 67: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/67.jpg)
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 &
![Page 68: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/68.jpg)
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.
![Page 69: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/69.jpg)
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.
![Page 70: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/70.jpg)
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
![Page 71: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/71.jpg)
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 72: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/72.jpg)
Introduction
PDS laboratory
Shut down
Getting started
![Page 73: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/73.jpg)
Introduction
PDS laboratory
Shut down
Getting started
Close all the windows you opened.
![Page 74: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/74.jpg)
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.
![Page 75: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/75.jpg)
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.
![Page 76: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/76.jpg)
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 77: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/77.jpg)
Introduction
PDS laboratory
Using emacs
Using emacs
![Page 78: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/78.jpg)
Introduction
PDS laboratory
Using emacs
Using emacs
emacs is a powerful text editor.
![Page 79: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/79.jpg)
Introduction
PDS laboratory
Using emacs
Using emacs
emacs is a powerful text editor.
Run emacs as: emacs myprog.c &
![Page 80: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/80.jpg)
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
![Page 81: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/81.jpg)
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 keys
![Page 82: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/82.jpg)
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.
![Page 83: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/83.jpg)
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)”
![Page 84: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/84.jpg)
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)
![Page 85: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/85.jpg)
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)
![Page 86: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/86.jpg)
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 87: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/87.jpg)
Introduction
PDS laboratory
Using gvim
Using gvim
![Page 88: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/88.jpg)
Introduction
PDS laboratory
Using gvim
Using gvim
gvim is another powerful text editor.
![Page 89: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/89.jpg)
Introduction
PDS laboratory
Using gvim
Using gvim
gvim is another powerful text editor.
Run gvim as: gvim myprog.c
![Page 90: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/90.jpg)
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
![Page 91: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/91.jpg)
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 mode
![Page 92: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/92.jpg)
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 mode
Hit Esc to exit insert mode
![Page 93: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/93.jpg)
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 mode
Hit Esc to exit insert mode
When in doubt, it is safe to hit Esc several times to comeback to view mode
![Page 94: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/94.jpg)
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 mode
Hit Esc to exit insert mode
When in doubt, it is safe to hit Esc several times to comeback to view mode
Navigate with mouse and cursor keys
![Page 95: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/95.jpg)
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 mode
Hit Esc to exit insert mode
When in doubt, it is safe to hit Esc several times to comeback to view mode
Navigate with mouse and cursor keys
You need to save the file by clicking on the appropriateicon (disk).
![Page 96: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/96.jpg)
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 mode
Hit Esc to exit insert mode
When in doubt, it is safe to hit Esc several times to comeback to view mode
Navigate 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 97: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/97.jpg)
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 98: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/98.jpg)
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 99: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/99.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
![Page 100: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/100.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .
![Page 101: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/101.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
![Page 102: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/102.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
![Page 103: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/103.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
Bypass proxy for local machines.
![Page 104: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/104.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
Bypass proxy for local machines.Type in a URL (web address) in the location field
![Page 105: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/105.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
Bypass proxy for local machines.Type in a URL (web address) in the location field
http://www.facweb.iitkgp.ernet.in/∼pds/
![Page 106: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/106.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
Bypass proxy for local machines.Type in a URL (web address) in the location field
http://www.facweb.iitkgp.ernet.in/∼pds/http://www.facweb.iitkgp.ernet.in/∼pds/notes/
![Page 107: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/107.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
Bypass proxy for local machines.Type in a URL (web address) in the location field
http://www.facweb.iitkgp.ernet.in/∼pds/http://www.facweb.iitkgp.ernet.in/∼pds/notes/http://www.facweb.iitkgp.ernet.in/∼adas/
![Page 108: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/108.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
Bypass proxy for local machines.Type in a URL (web address) in the location field
http://www.facweb.iitkgp.ernet.in/∼pds/http://www.facweb.iitkgp.ernet.in/∼pds/notes/http://www.facweb.iitkgp.ernet.in/∼adas/http://www.facweb.iitkgp.ernet.in/∼adas/course/lab/PDS/Spring06/
![Page 109: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/109.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
Bypass proxy for local machines.Type in a URL (web address) in the location field
http://www.facweb.iitkgp.ernet.in/∼pds/http://www.facweb.iitkgp.ernet.in/∼pds/notes/http://www.facweb.iitkgp.ernet.in/∼adas/http://www.facweb.iitkgp.ernet.in/∼adas/course/lab/PDS/Spring06/http://sit.iitkgp.ernet.in/∼chitta/courses/pds/slides/starter.html
![Page 110: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/110.jpg)
Introduction
PDS laboratory
Using a web browser
Using a web browser
Open a web browser: mozilla or konqueror .Set a proxy :
144.16.192.213:8080144.16.192.216:7777144.16.192.245:8080144.16.192.247:8080
Bypass proxy for local machines.Type in a URL (web address) in the location field
http://www.facweb.iitkgp.ernet.in/∼pds/http://www.facweb.iitkgp.ernet.in/∼pds/notes/http://www.facweb.iitkgp.ernet.in/∼adas/http://www.facweb.iitkgp.ernet.in/∼adas/course/lab/PDS/Spring06/http://sit.iitkgp.ernet.in/∼chitta/courses/pds/slides/starter.htmlhttp://10.14.0.4/ wbcm/
![Page 111: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/111.jpg)
Introduction
PDS laboratory
Assignments and submissions
Assignments and submissions
![Page 112: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/112.jpg)
Introduction
PDS laboratory
Assignments and submissions
Assignments and submissions
Click the link on the day’s assignment.
![Page 113: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/113.jpg)
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.
![Page 114: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/114.jpg)
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
![Page 115: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/115.jpg)
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
http://www.facweb.iitkgp.ernet.in/∼pds/2007s/notes.html
http://sit.iitkgp.ernet.in/∼chitta/courses/pds/slides/
![Page 116: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/116.jpg)
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
http://www.facweb.iitkgp.ernet.in/∼pds/2007s/notes.html
http://sit.iitkgp.ernet.in/∼chitta/courses/pds/slides/
Consult your lab instructor to know how to submit yourprograms.
![Page 117: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/117.jpg)
Introduction
PDS laboratory
Some useful Unix commands
Some useful Unix commands
![Page 118: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/118.jpg)
Introduction
PDS laboratory
Some useful Unix commands
Some useful Unix commands
Create a directory: mkdir progs
![Page 119: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/119.jpg)
Introduction
PDS laboratory
Some useful Unix commands
Some useful Unix commands
Create a directory: mkdir progs
Go to a new directory: cd progs/
![Page 120: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/120.jpg)
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 ../
![Page 121: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/121.jpg)
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
![Page 122: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/122.jpg)
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
![Page 123: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/123.jpg)
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
![Page 124: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/124.jpg)
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
![Page 125: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/125.jpg)
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
![Page 126: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/126.jpg)
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
![Page 127: Basic C programming tutorial](https://reader034.fdocuments.us/reader034/viewer/2022050815/546a5752b4af9fef7f8b4619/html5/thumbnails/127.jpg)
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