INTRODUCTION TO COMPUTER PROGRAMMING IN C

ODD SEMESTERS  (updated July 2018)

 

 

Course Objectives & Prerequisites:  

This course aims to introduce the students with Computer Programming Concepts, taking C language as the medium. The course lays emphasis on foundations & basic principles of Computer Programming. Beginning with elementary concepts, students will be presented with detailed discussions on a variety of programming constructs and advanced features of the C language.  

This course serves as first course in Computer programming and does not requires any special knowledge of Computer Science, except a basic familiarity with Digital Computers and Binary Numbers.   

Course Syllabus:  

Basic Programming Concepts: Introduction to the basic ideas of problem solving and programming using principles of top-down modular design, Flowcharts, Abstraction Mechanisms, Stepwise Refinement. Syntactic Elements of a Language, General Syntactic Criterion, Formal Definition of Syntax, Semantics, Storage Management.  

Introduction to Programming Language C: Data Types, Instruction and its Types, Storage Classes, Operators and  Hierarchy of Operations, Expressions in  C,  Control   and   Repetitive   Statements, break, continue,  Functions: User Defined Functions and Library Functions, Local and Global Variables, Parameter Passing, Pointers, Arrays, Strings, C Preprocessors, Structures, Input and Output in C, C-Library.  

Introduction to the Major Programming Paradigms: Imperative Language, Object Oriented Languages, Functional Languages, Logic Languages, Parallel Languages etc.  

Text Book:  

 

1. Kernighan & Ritchie, The C Programming Language, Pearson Education, 2/e.  

 

Reference Books:  

 

1.       R. Sethi, Programming Languages, Addison-Wesley, 1996

2.     Y. Kanetkar, Let Us C, BPB Publications.

3.     B.S.Gottfried, Schaum's Outline of Theory and Problems of Programming with C, Tata McGraw-Hill.

4.     H.Schildt, C Made Easy, Osborne McGraw-Hill.

Course Calendar:  

Lecture Slot

Topic

1

Introductory Lecture: Basic Discussion about Data Processing & Digital Computers, Layered View of Computing System.

2

Programming Basics: Stored Program Concept, Programming Languages, Idea of Syntax and Semantics, Design of Compiler.

3

Problem Solving: Idea of Algorithms, Flowcharts, Having a feel of Programming through Simple Programs.

4

The C Programming Language: Data Types, Operators, Expressions, C Statements, Writing Simple C Programs.

5

Control Structures: Sequence, Selection and Repetition Logic; C Constructs for Decisions and Loops.

6

Control Structures Continued: Nesting of Loops, Break and Continue, Pre and Post Increment and Decrement Operators.

7

Arrays: Array Declaration, Accessing Elements, Entering Data, Searching, Sorting, Matrix Operations.

8

Pointers: Address of and Value at Address Operators, Pointer Arithmetic, Arrays and Pointers.

9

Functions: User Defined and Library Functions, Defining Functions, Call by Value and Call by Reference, Arrays as Parameter, Recursive Functions.

10

Strings: Reading and Writing String Variables, String Manipulation, Library Functions for String Processing, Writing Own Library Functions.

11

Arrays, Pointers and Functions all Together.

12

Periodical Test 1.

13

Scope of Variables, Storage Classes, More Data Types, Type casting.

14

Structures.

15

Preprocessing: Macros, File Inclusion and Conditional Compilation.

16

I/O Functions: Console I/O, Disk I/O and Port I/O, Opening and Closing a File, File Opening Modes.

17

File Processing: Reading and Writing, Record I/O, File Pointer Manipulation, Command Line Arguments.

18

Dynamic Memory Allocation.

19

Bitwise Operations.

20

Leftover: Union , Enumeration, Functions with Variable Number of Arguments, Pointers to Functions and Functions Returning Pointers.

21

C Standard Library, Multi file Programs.

22

Periodical Test 2.

Additional-1

UNIX & C.

Additional-2

Programming Paradigms, Language Implementation, Structured Programming.

Laboratory Assignment 1  

1.      Write a Program to compute the Factorial value of a given integer. Use it to sum a given series.

 

2.      Write a Program to implement Sequential & Binary Search techniques on a given list of numbers.

 

3.      Write a Program to sort a given list of numbers in ascending order, using:

         (a) Bubble Sort       (b) Selection Sort        (c) Quick Sort        (d) Merge Sort

 

4.      Write a Program to perform following matrix operations:

         (a)    Compute transpose of a matrix

         (b)   Multiply two matrices.

 

5.      Write a Program to perform the following String Processing:

         (a)    To read a line of text and count the number of characters & words in it.

         (b)   To search for all the occurrences of a given sub string and replace it by its reverse.

 

6.      Write a Program to convert a positive integer into its Binary, Octal & Hexadecimal equivalent.

 

7.      Write a Program to solve the Tower of Hanoi problem for a given number of disks.

 

8.      Write a Program to copy the contents of one file to another. The program should read the file names at

         command prompt.

 

9.      Write a function rightrot (x , n) that returns the value of the integer x rotated to the right by n bit positions.

 

10.    Write a Program to create a linked list of items. Write functions for displaying the contents and inserting &

         deleting an item from the list.

 

11.    Write a Program to create a Stack containing numbers. Write appropriate functions for Push and Pop

         operations.

 

12.    Write a Program to create a Queue of items. Write appropriate functions for insertion and deletion

         operations. 

Laboratory Assignment 2

1. Write a Program to check a C program for rudimentary syntax errors like unbalanced parentheses, brackets and braces. 

    Ignore the Comment  lines.

 

2. Write a Program for Date Conversion, i.e., if a date (dd-mm-yyyy) is entered from the keyboard, the program should return 

    the day of the month and the day of the year. The program should check for invalid dates and should take into account the 

    leap years.

 

3. Write a Program expr which evaluates a reverse Polish expression from the command line, where each operator or operand

     is a separate argument. For ex.   expr 2 3 4 + * should evaluate to 2 * (3 + 4).

 

4. Write a Cross reference program that prints a list of all words in a document, and, for each word, a list of the line numbers

    on which it occurs.

 

5. Write a Program in C on UNIX which returns ids of a process, its parent and of all its children.

 

6. Write the C equivalent for UNIX command  ls to list the files in a directory.