Dr. Praveen Kumar >>Computer Programming


CSL101 : COMPUTER PROGRAMMING              [3-1-0, Credit : 4]

Pre-requisites : NIL                Type of Course : ES                 Semester : B. Tech. Sem I, II

Assessment : Sess- I  10% + Sess-II 15% + Lab 20% + TA 5% + End Sem 50%

Course Objectives :

The objective of the course is to introduce basics of programming and help students understand how to model real world problems as computational problem and develop logical and programming skills of students.

Course Outcomes: After the completion of the course, students will be able to:

CO1: Understand basics of a computer program and develop logical steps to solve a computational problem using computers.

CO2: Understand different programming constructs and their syntax in C language and use them to implement a C program.

CO3: Understand and implement more advanced concepts of C language like structures, pointers etc. along with their programming constructs.


Introduction : Fundamentals of Computer and programming, Program development and execution, basics of algorithm and flow charts

Basic C Constructs: Structure of C program, identifiers and keywords, variables, data types, Input/Output, Operators – arithmetic, relational, logical, conditional etc., Expressions – precedence and associativity, Type conversion, Decision making constructs including Switch case, Repetition/Loops – while/for/do-while

Basic Programming algorithms : Programs to illustrate basic language constructs in C like – Factorial, Sine/cosine and other mathematical series. Fibonacci series, calculating, square-root of a number, calculating GCD of 2 integers (Euclid’s method and otherwise), Calculating LCM of 2 integers and similar such programs.

More C constructs : Nested loops and examples like printing patterns, Functions – Declaration, Definition, function calls. Formal and actual parameters. Inter function communication by parameter passing, scope and lifetime of variables, storage classes, macros, Recursive functions. Arrays and applications : Introduction to one dimensional and 2-D array with examples. Sorting methods: Selection sort, Bubble sort, Insertion sort, Linear and binary search, partitioning an array, merging of 2 sorted arrays. Use of 2-D array to represent a matrix and matrix operations. Strings and designing your own string related functions as well as using library functions (strlen, strcpy, strcat, strcmp, atoi, itoa, reverse, strstr, etc).

Structures: Basic concept and syntax – tagged and typedef format, Defining and accessing structure members, array of structures, nested structures and application examples.

Pointers : Introduction (declaration and initialization), pointers and arrays, pointer arithmetic, concept of dynamic memory allocation, use of pointers to represent variable-sized 1-D and 2-D arrays, pointers to structures.

Reference Books :

  1. Kerninghan; Ritchie, “C Programming Language”, PHI
  2. Dromey R.G., “How to Solve it by Computer”, PHI
  3. Behrouz A. Forouzan, “Computer Science: A Structured Programming Approach Using C" , Cengage Learning
  4. Abhiram G. Ranade, "An Introduction to Programming through C++", McGraw-Hill Publishing
  5. Balguruswamy, “ Programming in ANSI C” Tata Mcgraw Hill Publishing
  6. Kakde and Deshpande, “C and data Structure”, Charles River Media Publisher


Sample Programming Problems for Lab

  1. Write a program to enter 3 numbers. Find out the greatest and smallest number out of the three.

            -Using If statement

            -Using relational operation

  1. Write a program to calculate energy bill. Read the starting and ending meter reading. The charges are as   follows.

                        No. of units                 Consumed Rates in (Rs)

                        200 – 500                    3.50

                        100 – 200                    2.50

                        Less than 100              1.50

  1. Write a program to implement a basic calculator performing four operations: addition, subtraction, multiplication, division. The program should display the menu of different operations and prompt user to enter his choice and perform the desired operation.
  2. Write a program to print out all Armstrong numbers between 1 and 999. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number.  For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
  3. Write a C program to print the prime numbers between 2 and 100.
  4. Write a C program to enter numbers till the user wants (number zero is an indication that there are NO more inputs) and at the end it should display the count of Positive and Negative numbers entered.
  5. Write a program to merge two already sorted array arrays A and B such that the resultant array C is also sorted. For Example: A = {10, 24, 46, 87, 99}

                              B = {2, 12, 18, 98, 105, 108}

                              C = {2, 10, 12, 18, 24, 46, 87, 98, 99, 105, 108}

  1. A test consisting of 5 questions is given to a batch of 3 students. Create a 2D array for storing the answers of 3 students for every question. Each question has one correct answer out of the four multiple choices provided with it. (You can choose to initialize the data in the program itself or take them input from the user). For each student, compute the number of correct answers and print the results.
  2. Write a utility function to compute the area of the triangle. Use this function to determine if any point (x4,y4) lies inside the triangle ABC (with coordinates A(x1,y1), B(x2,y2) and C(x3,y3)) or not.
  3. Write a recursive function countfib which calculates the number of calls made during calculation of a nth term of a Fibonacci sequence.
  4. Take a string as input from the user. Write a C program to output a string that contains all the vowels from the string and then all the consonants in the order of their appearance. For example, if the input string is "Ethernet" then the output should be "Eeethrnt".
  5. C Program to read roll number and other details (name, city) of 10 students using Structure and display the information of students in alphabetical order of student name.
  6. Declare a structure Employee which comprises of EmployeeID, Name and Salary. EmployeeID and Salary are int’s, whereas Name is a char string. Write a program to declare an array of 100 Employee’s and take input of EmployeeID, Name and Salary for these 100 employees. The program outputs the Name’s of Employee’s whose Salary is above 10000/-
  7. WAP to sort an array using bubble sort. Use a pointer variable to access the array with pointer arithmetic (without array indexing). Also write a swap function for interchanging values using pointers. Use this swap function for bubble sort.
  8. Create an array of 10 elements, traverse array from one end using p pointer variable and traverse array from another end using q pointer. Both the pointer variable traverse simultaneously, while traversing print the array element till both the pointer variable get same address.