Académique Documents
Professionnel Documents
Culture Documents
C PROGRAMMING LAB
(Common to ECE, AE during I B.Tech., I Semester)
(Common to EEE, CE, ME, CSE, IT during I B.Tech., II Semester)
Course Code(s) : AE1L2, EC1L3, CE2L3, ME2L3, CS2L3, IT2L3, EE2L3
Credits : 2
Internal Assessment : 25 marks
Lab : 3 Periods/week Semester end examination:50marks
Objectives:
To make the student learn a programming language.
To learn problem solving techniques.
To teach the student to write programs in C and to solve the problems.
Outcomes:
Students will be able to
Read, understand and trace the execution of programs written in C language.
Write the C code for a given algorithm.
Implement Programs with pointers and arrays, perform pointer arithmetic, and use the
pre-processor.
Write programs that perform operations using derived data types.
Syllabus:
Exercise 1:
Basics
1. Write a program to print sample strings like “hello world”, “Welcome to C
Programming” with different formats using escape sequences.
2. Write a Program to print different data types in „C‟ and their ranges.
3. Write a Program to initialize, assignment & printing variables of different data types.
Exercise 2:
Operators
1. Write a Program to demonstrate arithmetic operators. (+,-,*,/,%)
2. Write a Program to demonstrate logical operators.(logical AND, logical OR)
3. Write a Program to read radius value from the keyboard and calculate the area of
circle and print the result in both floating and exponential notation.
4. Write a Program to calculate simple interest.
5. Write a Program to convert temperature. (Fahrenheit –Centigrade and vice-versa)
Exercise 3:
Operators
1. Write a Program to demonstrate relational operators.(<,>,<=,>=,==,!=)
2. Write a program to check equivalence of two numbers using conditional operator.
3. Write a Program to demonstrate pre increment and post increment.(++a, a++ where a is a
value to be initialized)
4. Write a Program to demonstrate pre decrement and post decrement.(--a, a--where a is a
value to be initialized)
5. Write a program for computing the volume of sphere, cone and cylinder assume that
dimensions are integer‟s use type casting where ever necessary.
Exercise 4:
Decision Statements
1. Write a Program to read marks of a student in six subjects and print whether pass or fail (using
DEPARTMENT OF INFORMATION TECHNOLOGY
PRASAD V. POTLURI SIDDHARTHA INSTITUTE OF TECHNOLOGY
if-else).
2. Write a Program to calculate roots of quadratic equation (using if-else).
3. Write a Program to calculate electricity bill. Read starting and ending meter reading.
Exercise 5:
Switch operations
1. Write a Program to perform arithmetic operations using switch case.
2. Write a Program to display colors using switch case (VIBGYOR).
3. Write a Program to display vowels and consonants using switch case.
4. Write a Program to display names of days in a Week using switch case.
Exercise 6:
Basic Loop operations
Do the Following Programs Using for, while, do-while loops.
1. Write a program to calculate sum of individual digits of a given number.
2. Write a program to check whether given number is palindrome or not.
3. Write a program to print prime numbers in the given range.
4. Write a program to display multiplication tables from 1 to 10 except 3 and 5.
Exercise 7:
Advanced loops
1. Write a program to print the Fibonacci series for given „N‟ value.
2. Write a program to check whether a given number is a Fibonacci number or not.
3. Write a program to read 2 numbers x and n then compute the sum of the Geometric
Progression. 1+x+ x2+x3+ - - - - - - - +xn
4. Write a program to print the following formats.
1 *
12 * *
123 * * *
1234 * * * *
Exercise 8:
1-D arrays
1. Write a program to store 10 elements in the 1-D array and print sum of the array.
2. Write a program to print minimum and maximum elements in the 1-D array.
3. Write a program to count no. of positive numbers, negative numbers and zeros in the array.
4. Write a program to search the given element by using linear search.
5. Write a program to sort the given elements using bubble sort technique.
Exercise 9:
2-D arrays
1. Write a program to perform matrix addition and matrix subtraction.
2. Write a program to perform matrix multiplication by checking the compatibility.
3. Write a program to print the transpose of a matrix.
Exercise 10:
Strings
1. Write a program to perform various string manipulations using built-in functions.
2. Write a program to print the given strings in ascending order.
DEPARTMENT OF INFORMATION TECHNOLOGY
PRASAD V. POTLURI SIDDHARTHA INSTITUTE OF TECHNOLOGY
3. Write a program to verify the given string is palindrome or not (without built-in functions, with
using built-in functions).
4. Write a program to concatenate two strings using arrays.
Exercise 11:
Math Functions and I/O Functions
1. Write a program to read values from keyboard and find the values using
abs(),sqrt(),floor(),ceil()and pow().
2. Write a program to read and display a value using getch() and putch().
3. Write a program to read and display a value using getchar(), putchar(),gets() and
puts().
Exercise 12:
Functions
1. Write a program to find sum of two numbers using functions.
2. Write a program to find product of two numbers using functions without arguments, without
return type.
3. Write a program to find difference of two numbers using functions without arguments, with
return type.
4. Write a program to find sum of two numbers using functions with arguments &without return
type.
5. Write a program to find product of two numbers using functions with arguments, with return
type.
Exercise 13:
Functions and Recursion
1. Write a program to swap two numbers using Call By Value B) Call By Reference.
2. Write a program to calculate factorial, gcd using recursion and non-recursion functions.
3. Write program to perform arithmetic operations using pointer.
4. Write a program matrix addition using pointers.
Exercise 14:
Structures
1. Write a program to create structure for an account holder in a bank with following Fields: name,
account number, address, balance and display the details of five account holders.
2. Write a program to find total marks of individual student and average marks for 10 students
using structures.
3. Write a program to create structure called traveler and members of structure are train no, coach
no, seat no, source ,destination , gender, age, name and departure date.
4. Write a program to illustrate passing an entire structure to a function.
Exercise 15:
File operations using command line arguments
1. Write a program which copies the contents of one file to another file using command line
arguments.
2. Write a program to reverse the first n characters in a file use command line arguments.
Reference Books :
1. Problem Solving and Program Design in C, 4th Edition, by jeri R. Hanly and Elli B.Koffman.
2. Programming in C by Pradip Dey, Manas Ghosh 2nd Edition Oxford UniversityPress.
3. E. Balaguruswamy, Programming in ANSI C 5th Edition McGraw-Hill
4. A first book of ANSI C by Gray J.Brosin 3rd Edition Cengagedelmer Learning India P.Ltd
5. AL Kelly, Iraphol, Programming in C,4th Edition Addison-Wesley – Professional
6. Brain W.Kernighan & Dennis Ritchie, C Programming Language, 2 nd Edition, PHI