Programming in C

Course Code (Credit):

CUCS1001(2+4+0)

Course Objectives:

  • To gain a foundational understanding of the syntax and data types in C programming, and achieve proficiency in handling input/output using standard functions.
  • Learn to use operators and expressions effectively and implement control structures in C programs
  • To enhance problem-solving abilities by working with functions, recursion, arrays, strings, pointers, structures, and files.

Course Outcomes:

  • CO1: Define and record the fundamental syntax and data types used in the C programming language. (Remembering)
  • CO2: Describe and illustrate the usage of input/output functions and operators in C programming. (Understanding)
  • CO3: Demonstrate various operators and control structures to construct functional C programs.(Applying)
  • CO4: Examine and break down problems appropriate functions and recursion techniques for solution development. (Analysing)
  • CO5: Design and evaluate sophisticated algorithms and advanced C programs incorporating arrays, strings, pointers, structures, and unions. (Creating)

Course Syllabus:

Module I: Basic Syntax and Control Structures (20 hours):
Theory
  • Data Types and Variables
  • Basic Data Types: int, char, float, double
  • Variable Declaration and Initialization
  • Constants and Literals
  • Input/Output: printf(), scanf(), gets(), puts()
  • Operators and Expressions: Arithmetic, Relational, Logical, Bitwise, Assignment, Conditional (Ternary)
Practice Experiment
  • Experiment 1.1: Write a C program to demonstrate the use of variables and constants.
  • Experiment 1.2: Implement basic arithmetic operations using C.
  • Experiment 1.3: Develop a program to showcase the use of relational and logical operators.
  • Experiment 1.4: Write a program to perform input and output operations.
  • Experiment 1.5: Demonstrate the use of conditional operator in a C program.
  • Experiment 1.6: Implement a program using bitwise operators
  • Experiment 1.7: Write a C program to convert temperature from Celsius to Fahrenheit.
  • Experiment 1.8: Develop a program to swap two numbers without using a temporary variable.
  • Experiment 1.9: Write a program to find the maximum and minimum of three numbers.
  • Experiment 1.10: Implement a program to calculate the area of a circle.
Module II: Control Statements (20 hours)
Theory
  • if, if-else, nested if-else
  • switch-case
  • for loop, while loop, do-while loop
  • break, continue, goto, return
Practice Experiment
  • Experiment 2.1: Write a program using if-else statement to find the largest of three numbers.
  • Experiment 2.2: Implement a C program using switch-case to perform arithmetic operations.
  • Experiment 2.3: Develop a program to print the first 10 natural numbers using for loop.
  • Experiment 2.4: Write a C program to calculate the factorial of a number using while loop.
  • Experiment 2.5: Implement a program to reverse a given number using do-while loop.
  • Experiment 2.6: Develop a program to check whether a number is prime or not. /li>
  • Experiment 2.7: Write a C program to print Fibonacci series up to n terms.
  • Experiment 2.8: Implement a program to check whether a number is palindrome or not.
Module III: Functions and Recursion (30 hours)
Theory
  • Function Declaration, Definition, Call
  • Parameter Passing: Pass by Value, Pass by Reference
  • Scope and Lifetime of Variables
  • Inline Functions, Function Pointers
  • Recursion: Basics, Examples (Factorial, Fibonacci, Tower of Hanoi)
Practice Experiment
  • Experiment 3.1: Write a program to demonstrate the use of functions.
  • Experiment 3.2: Implement a program using recursion to find the factorial of a number.
  • Experiment 3.3: Develop a program to calculate the GCD of two numbers using recursion.
  • Experiment 3.4: Write a program to find the nth Fibonacci number using recursion.
  • Experiment 3.5: Implement a program to demonstrate pass by value and pass by reference.
  • Experiment 3.6: Develop a program using function pointers.
  • Experiment 3.7: Write a C program to find the sum of an array using recursion.
  • Experiment 3.8: Implement a program to solve the Tower of Hanoi problem.
Module IV: Arrays and Strings (20 hours)
Theory
  • One-Dimensional Arrays, Multidimensional Arrays
  • Array as Function Arguments
  • Strings: Declaration, Initialization
  • String Manipulation Functions: strcpy(), strcat(), strcmp(), strlen(), etc.
  • Array of Strings
Practice Experiment
  • Experiment 4.1: Write a C program to implement linear search in an array.
  • Experiment 4.2: Implement a program to sort an array using bubble sort.
  • Experiment 4.3: Develop a program to perform matrix addition.
  • Experiment 4.4: Write a program to perform matrix multiplication.
  • Experiment 4.5: Implement a program to reverse a string.
  • Experiment 4.6: Develop a program to check whether a string is palindrome.
  • Experiment 4.7: Write a C program to concatenate two strings without using library functions.
  • Experiment 4.8: Implement a program to find the length of a string using a user-defined function.
Module V: Pointers (20 hours)
Theory
  • Pointer Declaration, Initialization
  • Pointer Arithmetic
  • Pointers and Arrays, Strings
  • Advanced Pointers: Pointers to Pointers, Function Pointers
  • Dynamic Memory Allocation: malloc(), calloc(), realloc(), free()
Practice Experiment
  • Experiment 5.1: Write a C program to demonstrate pointer arithmetic.
  • Experiment 5.2: Implement a program to swap two numbers using pointers.
  • Experiment 5.3: Develop a program to reverse an array using pointers.
  • Experiment 5.4: Write a C program to find the length of a string using pointers.
  • Experiment 5.5: Implement a program to copy one string to another using pointers
  • Experiment 5.6: Develop a program to dynamically allocate memory for an array.
  • Experiment 5.7: Write a C program to demonstrate the use of function pointers.
  • Experiment 5.8: Implement a program to demonstrate double pointer.
Module VI: Structures and Unions (10 hours)
Theory
  • Defining and Declaring Structures, Accessing Members
  • Array of Structures, Passing Structures to Functions, Pointers to Structures
  • Defining and Declaring Unions, Difference between Structures and Unions
Practice Experiment
  • Experiment 6.1: Write a C program to define and use a structure.
  • Experiment 6.2: Implement a program to demonstrate array of structures.
  • Experiment 6.3: Develop a program to pass structure to a function.
  • Experiment 6.4: Write a C program to demonstrate the use of pointers to structures.
  • Experiment 6.5: Implement a program to define and use a union.
  • Experiment 6.6: Develop a program to demonstrate the difference between structures and unions.
  • Experiment 6.7: Write a C program to implement a student record system using structures.
  • Experiment 6.8: Implement a program to calculate the size of a structure using sizeof operator.
Module VII: Advanced Topics (20 hours)
Theory
  • File I/O: fopen(), fclose(), fread(), fwrite(), fprintf(), fscanf()
  • Error Handling in File Operations
  • Bitwise Operations and Preprocessor Directives
Practice Experiment
  • Experiment 7.1: Write a C program to perform file I/O operations.
  • Experiment 7.2: Implement a program to demonstrate error handling in file operations.
  • Experiment 7.3: Develop a program to perform bitwise operations.
  • Experiment 7.4: Write a C program to demonstrate the use of preprocessor directives.
  • Experiment 7.5: Implement a program to perform operations on bits.
  • Experiment 7.6: Develop a program to demonstrate the use of macros.
  • Experiment 7.7: Write a C program to implement a simple calculator using functions.
  • Experiment 7.8: Implement a program to demonstrate command-line arguments.

Text Books:

  1. Byron Gottfried, “Programming with C” TMH Publications
  2. Ashok and Kamthane ’Computer Programming” Pearson Education.

Reference Books:

  1. E. Balaguruswamy “Programming in C”, Tata McGraw Hill-3rd edition
  2. B.W. Kernighan & D.M. Ritchie, "C Programming Language", PHI.
  3. T Jeyapoovan, A First Course in Programming with C, Vikas Publishing House Pvt Ltd.

Session Plan:

Session Topic Reference Link (if any)
Session 1 Algorithms, Flow charts, Pseudo codes, Structured programming-sequence, selection and iterations. Coursera
YouTube
Session 2 Overview of C, Structure of C program, Character set, Identifiers, Keywords, Constants, Variables. YouTube 1
Coursera
YouTube 2
Session 3 Data Types: Size and range of data types, type conversions. Coursera
YouTube
Session 4 (Assignment 1) Explain flow chart, algorithm & pseudo code.
Describe tokens briefly.
What is data type? What are its types? Explain.
Session 5 (Practice 1) Demonstrate all the data types by taking variables. YouTube
Session 6 Arithmetic operator. Coursera
YouTube
Session 7 Relational and logical operators. Coursera
YouTube
Session 8 Increment and decrement operators. YouTube
Session 9 Conditional operator. YouTube
Session 10 Bitwise operators, Assignment operators. YouTube
Session 11 Reading a character, writing a character, formatted I/O. Coursera
YouTube
Session 12 Decision making - if statement, if-else statement, nested if-else, else-if ladder, switch statement. Coursera
YouTube
Session 13 Loops - while loop, do-while loop, for loop, nested loops, break and continue statements. Coursera
YouTube
Session 14 (Practice 2) Print prime numbers using for loop, print factorial of a number.
Session 15 Arrays: Introduction, declaration, initialization and accessing array elements, arrays and loops. Coursera
YouTube
Session 16 Character arrays, String functions. Coursera
YouTube
Session 17 Multidimensional arrays. Coursera
YouTube
Session 18 (Assignment 2) Write a program to sort 10 elements.
Write a program to print 10 strings and sort them.
Session 19 Functions: Declaration, definition, function call, types of functions. Coursera
YouTube
Session 20 Call by value and call by reference, recursion. YouTube
Session 21 Storage classes in C. YouTube
Session 22 Pointers: Introduction, declaration, initialization, accessing value using pointers. YouTube
Session 23 Pointer arithmetic, pointer and arrays, pointer to pointer. YouTube
Session 24 Pointers and functions. YouTube
Session 25 (Practice 3) Write a program to swap two numbers using call by value and call by reference.
Session 26 Structures: Declaring, defining and initializing a structure, array of structure. Coursera
YouTube
Session 27 Nested structures, structure pointer, union. YouTube
Session 28 File handling - opening a file, reading a file, writing to a file. YouTube
Session 29 File modes, file functions, fseek(), rewind(), ftell(). YouTube
Session 30 Preprocessor directives, #define, #include, macro expansion, conditional compilation. YouTube
Session 31 Bitwise operators, Command line arguments. YouTube
Session 32 Dynamic memory allocation: malloc(), calloc(), realloc(), free(). YouTube
Session 33 Practice 4 – File handling and structures.
Session 34 Assignment 3 – Write a program using structure and file handling to store employee details.
Session 35 Project explanation session – Guidelines and ideas for final mini project.
Session 36 Mini Project Work (Group discussion & initial coding).
Session 37 Mini Project Implementation – Phase 1.
Session 38 Mini Project Implementation – Phase 2.
Session 39 Project completion & submission.
Session 40 Project presentation (Internal Evaluation).
Session 41 Revision - Fundamentals, operators, input/output, conditional statements.
Session 42 Revision - Loops and nested loops.
Session 43 Revision - Functions and arrays.
Session 44 Revision - Strings and pointers.
Session 45 Revision - Structures and file handling.
Session 46 Practice – Final practical exam sample questions.
Session 47 Doubt clearing session (Assignment & Project related).
Session 48 Class test – Full syllabus.
Session 49 Evaluation of class test and doubt clarification.
Session 50 Assignment review & feedback.
Session 51 Project review & final submission.
Session 52 Lab internal preparation and viva practice.
Session 53 Final internal lab exam – Part 1.
Session 54 Final internal lab exam – Part 2.
Session 55 Course wrap-up & feedback collection.