Name: ____________________________ Registration Number:_____________________
Programming in C
B.Tech. 2nd Semester
Name : P SNEHA
Reg Number : 23ETCS002083
Programme : Btech
Department :Computer Science Engineering
Faculty of Engineering & Technology
Ramaiah University of Applied Sciences
1
Name: ____________________________ Registration Number:_____________________
Ramaiah University of Applied Sciences
Private University Established in Karnataka State by Act No. 15 of 2013
Faculty Engineering & Technology
Programme B. Tech. in Computer Science and Engineering
Year/Semester 1st Year /2nd Semester
Name of the Laboratory Programming in C
Laboratory Code CSD105A
List of Experiments
Introduction to C programs
Conditional statements
Loops and Arrays
Functions and Recursion
Pointers
Structures
Files
2
Name: ____________________________ Registration Number:_____________________
Index Sheet
No Lab Experiment Lab document Viva
1 Introduction to C programs Lab document
10% of Lab CE
2 Conditional statements Lab document
10% of Lab CE
3 Loops and Arrays Lab document
10% of Lab CE
4 Functions and Recursion Lab document
10% of Lab CE
5 Pointers Lab document
10% of Lab CE
6 Structures Lab document
10% of Lab CE
7 Files Lab document
10% of Lab CE
8 Lab Internal Test 30% of Lab CE
3
Name: ____________________________ Registration Number:_____________________
Laboratory 1
Title of the Laboratory Exercise: Introduction to C programming
1. Introduction and Purpose of Experiment
C is a powerful general-purpose programming language. It can be used to develop software
like operating systems, databases, compilers, and so on. C. In this laboratory exercise,
students get familiar with the program development tool such as netbeans IDE to edit and
run C programs using a set of simple exercises.
2. Aim and Objectives
Aim
To familiarise IDE and simple C programs
Objectives
At the end of this lab, the student will be able to
Explain the features and use of IDE to develop C programs
Edit and execute simple C programs
3. Experimental Procedure
Students are given a set of C programs. Edit and execute C programs using netbeans IDE
i. Analyse the problem statement
ii. Problem solving approach for the given problem statement and develop
algorithm
iii. Implement the algorithm in C language
iv. Execute the C program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a C program to print Hello World.
b. Write a C program to calculate the area of a circle.
c. Write a C program to experiment on escape sequences.
4
Name: ____________________________ Registration Number:_____________________
5. Problem Solving Logic and Algorithm
a)
i. Problem Solving Logic
A) 1) Declare the header file stdio.h.
2) Under Void main() function ,use printf() to display Hello World .
ii. Algorithm
A) Algorithm
begin
writeln(“ Hello World “)
end
b)
6. Program with Test cases
a)
i) Program
A)
ii) Test cases
b)
7. Summary
i) Limitations of Experiments and/or Results
ii) Recommendations
iii) Learning happened
5
Name: ____________________________ Registration Number:_____________________
6
Name: ____________________________ Registration Number:_____________________
Laboratory 2
Title of the Laboratory Exercise: Conditional statements
1. Introduction and Purpose of Experiment
C provides number of control flow instructions/statements to control the flow of program
execution conditionally. By solving the problems, students will be able to apply conditional
control statements to control the program execution.
2. Aim and Objectives
Aim
To develop programs involving branching using appropriate control statements in
C
Objectives
At the end of this lab, the student will be able to
Apply conditional control statements such as if-else and nested if-else to express
decisions
3. Experimental Procedure
viii. Analyse the problem statement
ix. Problem solving approach for the given problem statement and develop
algorithm
x. Implement the algorithm in C language
xi. Execute the C program
xii. Test the implemented program
xiii. Document the Results
xiv. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a C program to test if a number is zero, positive or negative.
b. Write a C program to find minimum of three numbers.
c. Write a C program to display the roots of a quadratic equation.
5. Problem Solving Logic and Algorithm
a)
7
Name: ____________________________ Registration Number:_____________________
i. Problem Solving Logic
ii. Algorithm
b)
6. Program with Test cases
a)
i) Program
ii) Test cases
b)
7. Summary
i) Limitations of Experiments and/or Results
ii) Recommendations
iii) Learning happened
8
Name: ____________________________ Registration Number:_____________________
Laboratory 3
Title of the Laboratory Exercise: Loops and Arrays
1. Introduction and Purpose of Experiment
Loop statements are used to repeat a statement or set of statements multiple times. By
solving the problems students will be able to apply iterative control statements to control
the program execution. An array is a data structure consisting of a collection of elements
(values or variables), of same memory size, each identified by at least one array index or key.
2. Aim and Objectives
Aim
To develop programs involving loops using appropriate control statements in C
Objectives
At the end of this lab, the student will be able to
Apply loop control statements such as for , do while and while to repeat a block of
code
3. Experimental Procedure
i. Analyse the problem statement
ii. Problem solving approach for the given problem statement and develop algorithm
iii. Implement the algorithm in C language
iv. Execute the C program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a C program which uses the formula C= (5/9)*(F-32) to print a table of Fahrenheit
temperatures and their centigrade or Celsius equivalents from 1 to 300 Fahrenheit
temperature.
b. Write a C program to perform matrix addition and multiplication
5. Problem Solving Logic and Algorithm
a)
9
Name: ____________________________ Registration Number:_____________________
i. Problem Solving Logic
ii. Algorithm
b)
6. Program with Test cases
a)
i) Program
ii) Test cases
b)
7. Summary
i) Limitations of Experiments and/or Results
ii) Recommendations
iii) Learning happened
10
Name: ____________________________ Registration Number:_____________________
Laboratory 4
Title of the Laboratory Exercise: Functions and Recursion
1. Introduction and Purpose of Experiment
A function serves as an abstraction mechanism to view many things as one thing. The
function definition specifies the name of a new function and the sequence of statements
that execute when the function is called. Once a function is defined, it can be called as many
times as required. By solving these problems, students will be able to create user defined
functions. A recursive function solves a particular problem by calling a copy of itself and
solving smaller sub-problems of the original problems.
2. Aim and Objectives
Aim
To develop programs using user defined functions
Objectives
At the end of this lab, the student will be able to
Apply user defined functions and concept of recursions with proper definition
3. Experimental Procedure
i. Analyse the problem statement
ii. Problem solving approach for the given problem statement and develop algorithm
iii. Implement the algorithm in C language
iv. Execute the C program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a) Write a C program to determine the type of a triangle using functions.
b) Write a C program to find the following using iteration and recursion
fibonacci numbers
factorial
power
11
Name: ____________________________ Registration Number:_____________________
5. Problem Solving Logic and Algorithm
a)
i. Problem Solving Logic
ii. Algorithm
b)
6. Program with Test cases
a)
i) Program
ii) Test cases
b)
7. Summary
i) Limitations of Experiments and/or Results
ii) Recommendations
iii) Learning happened
12
Name: ____________________________ Registration Number:_____________________
Laboratory 5
Title of the Laboratory Exercise: Pointers
1. Introduction and Purpose of Experiment
A pointer is defined as a derived data type that can store the address of other C variables or
a memory location. We can access and manipulate the data stored in that memory location
using pointers. As the pointers in C store the memory addresses, their size is independent of
the type of data they are pointing to.
2. Aim and Objectives
Aim
To develop programs to understand the concept of pointers in C
Objectives
At the end of this lab, the student will be able to
Apply pointers to solve problems
3. Experimental Procedure
i. Analyse the problem statement
ii. Problem solving approach for the given problem statement and develop algorithm
iii. Implement the algorithm in C language
iv. Execute the C program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a) Write a C program to swap two numbers using pointers
b) Write a C program to perform the following using pointers
I. String copy
II. String compare
III. String length
5. Problem Solving Logic and Algorithm
a)
i. Problem Solving Logic
13
Name: ____________________________ Registration Number:_____________________
ii. Algorithm
b)
6. Program with Test cases
a)
i) Program
ii) Test cases
b)
7. Summary
i) Limitations of Experiments and/or Results
ii) Recommendations
iii) Learning happened
14
Name: ____________________________ Registration Number:_____________________
Laboratory 6
Title of the Laboratory Exercise: Structures
1. Introduction and Purpose of Experiment
A structure is an arrangement and organization of interrelated elements in a material object
or system, or the object or system so organized. Unlike an array, a structure can contain
many different data types (int, float, char, etc.).
2. Aim and Objectives
Aim
To develop programs using user defined structures
Objectives
At the end of this lab, the student will be able to
Apply user defined structures with proper definition
3. Experimental Procedure
i. Analyse the problem statement
ii. Problem solving approach for the given problem statement and develop algorithm
iii. Implement the algorithm in C language
iv. Execute the C program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a C program to create and display a record for each student in your class with
fields Reg no, Name and Age.
b. Modify the above program to calculate grade for each subject for all students in 1 st
semester.
5. Problem Solving Logic and Algorithm
a)
i. Problem Solving Logic
ii. Algorithm
15
Name: ____________________________ Registration Number:_____________________
b)
6. Program with Test cases
a)
i) Program
ii) Test cases
b)
7. Summary
i) Limitations of Experiments and/or Results
ii) Recommendations
iii) Learning happened
16
Name: ____________________________ Registration Number:_____________________
Laboratory 7
Title of the Laboratory Exercise: File handling
1. Introduction and Purpose of Experiment
A text file is a sequence of characters stored on a permanent medium such as hard drive,
flash memory, and CD-ROM. In C, instead of printing results to screen using print, results can
be written to a file. A file is used to open a connection to a text file for input or output. By
solving these problems, students will be able to perform file handling functions.
2. Aim and Objectives
Aim
To develop programs using file handling functions
Objectives
At the end of this lab, the student will be able to
Apply file handling functions for solving problems
3. Experimental Procedure
i. Analyse the problem statement
ii. Problem solving approach for the given problem statement and develop algorithm
iii. Implement the algorithm in C language
iv. Execute the C program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a C program to copy the contents from one file to another.
b. Write a C program to count characters, word and lines in a given file.
5. Problem Solving Logic and Algorithm
a)
i. Problem Solving Logic
17
Name: ____________________________ Registration Number:_____________________
ii. Algorithm
b)
6. Program with Test cases
a)
i) Program
ii) Test cases
b)
7. Summary
i) Limitations of Experiments and/or Results
ii) Recommendations
iii) Learning happened
18
Name: ____________________________ Registration Number:_____________________
19