C Programming (CSC 115)
Lab Manual
For ([Link])
Page 1 of 7
Introduction to Students for Preparing C
Programming Lab Report
This Lab Manual is prepared to help the students with their practical
understanding and development of programming skills, and may be used as a
base reference during the lab/practical classes.
Students have to prepare Lab report of all lab done in class. At the end of the
semester, students should compile all the Lab Exercise reports into a single
report and submit during the end semester sessional examination.
Sample of Lab report for your reference, “how to write a complete lab report”
is shown in this manual.
The lab report to be submitted should include at least the following topics:
1. Cover page
2. Title
3. Objective(s)
4. Algorithm
5. Flowchart
6. Coding
7. Output (compilation, debugging & testing)
8. Discussion & Conclusion.
Page 2 of 7
(Sample Cover page, please use your own university/college name& department for your lab report submission)
Butwal Multiple Campus
Tribhuvan University
Butwal, Rupandehi, Nepal
Lab Report on Programming in C
Faculty of [Link]. CSIT
Tribhuvan University
Kritipur, Nepal
Submitted By
Name: Your Name (Section)
Roll No: Your Roll no
Submitted To
Butwal Multiple Campus
Department of BSC CSIT
Butwal, Rupandehi Nepal
Signature Internal Examiner External Examiner
Page 3 of 7
Objective(s):
• To be familiar with syntax and basic building blocks such as
constants, variables, keywords and input output statements in C
language.
• To learn problem solving techniques using C
Program:
Write a Program to calculate the volume of a CUBE having its height
(h=20cm), width (w=24cm), depth (16cm) and display the result.
Algorithm:
1. Start
2. Define variables: h(int), w(int), d(int), V(int)
3. Assign value to variables: h = 20, w=24, d=16
4. Calculate the volume as: V = h*w*d
5. Display the volume (V)
6. Stop
Flowchart:
Start
Define h, w, d, V
h=20, w = 24, d = 16;
V = h*w*d
Print V
End
Page 4 of 7
Code:
//Following code is written and compiled in Code::Blocks IDE using GCC
#include<stdio.h>
int main(void)
{ //start the program
int h, w, d, v; //variables declaration
h=20; w=24; d=16; //assign value to variables
v=h*w*d; //calculation using mathematical formula
printf("The volume of the cube is: %d", v); //display the volume
return 0; //end the main program
}
Output:
The Volume of the cube is: 7680
Discussion and Conclusion:
The program is focused on the calculation of volume of a cube
for the given height, width and depth. This program helps to
understand the basic structure of C programming including the
meaning of header files & steps of problem solving. Hence, volume of
a cube is calculated and displayed. Study about basic building blocks
such as constants, variables, keywords,operators, expressions and
input output statements in C language.
Instructions:
• Write comments to make programs readable
• Use descriptive variables in programs (Name of the
variables should show their purposes)
Page 5 of 7
Lab Exercises (Programs List):
1. Write a C program to find the area and volume of sphere and display the
results. Formulas are:-
Area = 4*PI*R*R Volume = 4/3*PI*R*R*R.
Note : Assume PI=3.14 and take the value of R from user
2. Write a program to evaluate the area of triangle with 3 sides given and display
the result (take the value of sides from user as input).
[Hints: area=sqrt(s(s-a)(s-b)(s-c)) where a,b,c are the sides of the triangle and
s=(a+b+c)/2]
3. Write a C program to find the sum of individual digits of a 3 digit number.
4. Write a program to swap two variables values with or without using third
Variable.
5. Write a program to compute amount of electric bill as per charge below:
No of Units Consumed Rates (In Rs.)
500 and above 5.50
200-500 3.50
100-200 2.50
Less than 100 1.50
6. Write a C program which takes two integer operands and one operator from
the user, performs the operation and then prints the result. (Consider the
operators +,-,*, /, % and use Switch Statement)
7. WAP to perform multiplication of two matrices and display the result.
8. WAP to determine if the given string is a palindrome or not. (A string is
palindrome if its half is mirror by itself eg: abcdcba).
9. WAP to check whether a number is prime, Armstrong or perfect number
using functions.
[Link] that uses functions to perform Matrix addition and subtraction on two
Matrices.
[Link] to add, subtract, multiply and divide two numbers using pointers.
[Link] to find length of a given string including and excluding spaces using
pointers.
Page 6 of 7
13. WAP to read RollNo, Name, Address, Age & marks in physics, C, math in 1st
semester of three students in BoCE and display the student details with
average marks achieved.
[Link] a C program to compute the monthly pay of employee using each
employee’s name, basic pay. The DA is computed as 52% of the basic pay.
Gross-salary (basic pay + DA). Print the employees name and gross salary.
Page 7 of 7