0% found this document useful (0 votes)
72 views

C Programming Lab Module - I: Dear Students

The document introduces a C programming lab module that focuses on programming structure and lab report requirements. Students will complete 8-10 programming exercises and submit lab reports following a specific format. The first exercise is to write a program to calculate the volume of a cube given its height, width, and depth. The program defines variables to store the height, width, depth, and calculated volume. It assigns values to the height, width, and depth, calculates the volume using the formula, and prints the result. Running the program outputs the volume of 960.

Uploaded by

Sushant Pradhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

C Programming Lab Module - I: Dear Students

The document introduces a C programming lab module that focuses on programming structure and lab report requirements. Students will complete 8-10 programming exercises and submit lab reports following a specific format. The first exercise is to write a program to calculate the volume of a cube given its height, width, and depth. The program defines variables to store the height, width, depth, and calculated volume. It assigns values to the height, width, and depth, calculates the volume using the formula, and prints the result. Running the program outputs the volume of 960.

Uploaded by

Sushant Pradhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

C PROGRAMMING LAB MODULE I

Structure Of C programming

Dear Students,
Welcome to C programming Lab. For the practical works of C programming, you have to
complete at least eight to ten lab activities throughout the course. These lab sheets will guide you
to prepare for programming and submission of lab reports. Further, it helps you to understand
practically about the knowledge of programming. You can use this lab guide as the base reference
during your lab.
You have to submit lab report of previous lab into corresponding next lab during when your
instructor shall take necessary VIVA for your each lab works. For your reference, how to write
a complete lab report? is being prepared as sample report for LAB sheet #1 and LAB sheet #2
in this manual. For the rest of your labs, please follow the reporting style as provided. Your lab
report to be submitted should include at least the following topics.
1.

Cover page

2.

Title

3.

Objective(s)

4.

Problem Analysis

5.

Algorithm

6.

Flowchart

7.

Coding

8.

Output (compilation, debugging & testing)

9.

Discussion & Conclusion.

On each lab, you have to submit the report as mentioned above however for additional lab
exercises; you have to show the coding and output to your instructor.
Note: The lab exercises shall not be completed in a single specific lab. Students are encouraged
to complete the programming questions given in the exercise prior to come to the lab hour and
do the lab for the given title/objectives.

Objective(s):
-To be familiar with syntax and structure of Cprogramming.
-To learn problem solving techniques using C

C Programming Lab Sheet


Write a Program to calculate and display the volume of a CUBE having its height (h=10cm),
width (w=12cm) and depth (8cm).

Problem Analysis:
The problem is to calculate the volume of a CUBE having its inputs parameters identified
as:Height (integer type), width (integer type) and depth (integer type). The output of the program
is to display the volume; hence the output parameter is identified as vol (integer type). During the
processing or calculation phase, we dont need any extra parameters (variables) for this problem.
The volume of the cube is the multiplication of its height, width and depth, hence the
mathematical formula to calculate volume is:
vol = height* width* depth. (vol = h*w*d)

Input
variables

Processing
variables/calculations

Output
variables

Necessary header
files/functions/macros

h(int)
w(int)
d(int)

vol = h*w*d

vol
(int)

stdio.h

Algorithm:
1.
2.
3.
4.
5.
6.

Start
Define variables: h(int), w(int), d(int), vol(int)
Assign value to variables: h = 10, w=12, d=8
Calculate the volume as: vol = h*w*d
Display the volume (vol)
Stop

Flowchart:
START
int h, w,d,vol

h=10; w=12;d=8;
vol=h*w*d;

Print vol

STOP

450/ From the Book: Capsules of C Programming

Code:
//Following code is written and compiled in Turbo C

IDE

#include<stdio.h>
#include<conio.h>
void main() {
//start the
inth,w,d,vol;
h=10;w=12;d=8;

//variables

declaration

//assign value to variables

clrscr();
vol=h*w*d; //calculation using mathematical
printf("The Volume of the cube is: %d",vol); //display the volume
getch();
}

Output (Compilation, Debugging & Testing)


The Volume of the cube is: 960

Discussion and Conclusion


This is the first code written in C program. The program is focused on the calculation of volume
of a cube for the given height, width and depth. From this lab, I understood 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.

Lab exercises (please code yourself and show the output to instructor):
1.

Write a program to display hello world in C.

2.

Write a program to add two numbers (5&7) and display its sum.

3.

Write a program to multiply two numbers (10&8) and display its product.

4.

Write a program to calculate area of a circle having its radius (r=5).

5.

Write a program to calculate area of an ellipse having its axes (minor=4cm, major=6cm).

6.

Write a program to calculate simple interest for a given P=4000, T=2, R=5.5. (I =
P*T*R/100)

You might also like