CS3271 -
PROGRAMMING IN C
LABORATORY
COURSE OBJECTIVES:
• To familiarize with C programming constructs.
• To develop programs in C using basic constructs.
• To develop programs in C using arrays.
• To develop applications in C using strings, pointers, functions.
• To develop applications in C using structures.
• To develop applications in C using file processing.
COURSE OUTCOMES:
• Upon completion of the course, the students will be able to
• CO1: Demonstrate knowledge on C programming constructs.
• CO2: Develop programs in C using basic constructs.
• CO3: Develop programs in C using arrays.
• CO4: Develop applications in C using strings, pointers, functions.
• CO5: Develop applications in C using structures.
• CO6: Develop applications in C using file processing.
LIST OF EXPERIMENTS
1. I/O statements, operators, expressions
2. decision-making constructs: if-else, goto, switch-case, break-continue
3. Loops: for, while, do-while
4. Arrays: 1D and 2D, Multi-dimensional arrays, traversal
5. Strings: operations
6. Functions: call, return, passing parameters by (value, reference), passing arrays to
function.
7. Recursion
8. Pointers: Pointers to functions, Arrays,Strings, Pointers to Pointers, Array of Pointers
9. Structures: Nested Structures, Pointers to Structures, Arrays of Structures and Unions.
10. Files: reading and writing, File pointers, file operations, random access, processor
directives.
• TEXT BOOKS:
• 1. ReemaThareja, “Programming in C”, Oxford University Press, Second Edition, 2016.
• 2. Kernighan, B.W and Ritchie,D.M, “The C Programming language”, Second Edition, Pearson
Education, 2015.
• REFERENCES:
• 1. Paul Deitel and Harvey Deitel, “C How to Program with an Introduction to C++”, Eighth edition,
Pearson Education, 2018.
• 2. Yashwant Kanetkar, Let us C, 17th Edition, BPB Publications, 2020.
• 3. Byron S. Gottfried, "Schaum's Outline of Theory and Problems of Programming with C", McGraw-
Hill Education, 1996.
• 4. Pradip Dey, Manas Ghosh, “Computer Fundamentals and Programming in C”, Second
• 5. Edition, Oxford University Press, 2013.
• 6. Anita Goel and Ajay Mittal, “Computer Fundamentals and Programming in C”, 1st Edition,
Pearson Education, 2013.
Sample Programs
1. Program to print text
#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf(“AAMEC - IT DEPT!");
return 0;
}
2. Program to Print an Integer
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
// reads and stores input
scanf("%d", &number);
// displays output
printf("You entered: %d", number);
return 0;
}
3. Program to Add Two Integers
#include <stdio.h>
int main() {
int number1, number2, sum;
printf("Enter two integers: ");
scanf("%d %d", &number1, &number2);
// calculate the sum
sum = number1 + number2;
printf("%d + %d = %d", number1, number2, sum);
return 0;
}
4. Program to Multiply Two
Numbers
#include <stdio.h>
int main() {
double a, b, product;
printf("Enter two numbers: ");
scanf("%lf %lf", &a, &b);
// Calculating product
product = a * b;
// %.2lf displays number up to 2 decimal point
printf("Product = %.2lf", product);
return 0;
}
5. Find the Size of Variables
#include<stdio.h>
int main() {
int intType;
float floatType;
double doubleType;
char charType;
// sizeof evaluates the size of a variable
printf("Size of int: %zu bytes\n", sizeof(intType));
printf("Size of float: %zu bytes\n", sizeof(floatType));
printf("Size of double: %zu bytes\n", sizeof(doubleType));
printf("Size of char: %zu byte\n", sizeof(charType));
return 0;
}