0% found this document useful (0 votes)
0 views3 pages

Lab 1

The document outlines a lab exercise focused on C programming, including objectives to understand syntax and problem-solving techniques. It provides a specific program to calculate the volume of a cube with given dimensions, along with an algorithm, flowchart, and sample code. Additionally, it lists several other programming tasks for students to complete, emphasizing the importance of comments and descriptive variable names.

Uploaded by

aishorjoshuchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views3 pages

Lab 1

The document outlines a lab exercise focused on C programming, including objectives to understand syntax and problem-solving techniques. It provides a specific program to calculate the volume of a cube with given dimensions, along with an algorithm, flowchart, and sample code. Additionally, it lists several other programming tasks for students to complete, emphasizing the importance of comments and descriptive variable names.

Uploaded by

aishorjoshuchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

LAB :1

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

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

Algorithm:
1. Start
2. Define variables: h(int), w(int), d(int), vol(int)
3. Assign value to variables: h = 10, w=12, d=8
4. Calculate the volume as: vol = h*w*d
5. Display the volume (vol)
6. Stop

Flowchart:
Code: (Use comments wherever applicable)

#include<stdio.h>
void main()
{
//start the program
int h,w,d,vol; //variables declaration
h=10;w=12;d=8; //assign value to variables
vol=h*w*d; //calculation using mathematical formula
printf("The Volume of the cube is: %d",vol); //display the volume
getch();
//end the main program
}
Output :
The Volume of the cube is: 960

SAMPLE PROGRAMS

(Students are to code the following programs in the lab and show the output
to instructor/course teacher)
Instructions

• Write comment to make your programs readable.


• Use descriptive variables in your programs(Name of the variables should show
their purposes)

Programs List

1. Write a C program to display “This is my first C Program”.


2. Write a C program to add two numbers (2 and 6) and display its sum.
3. Write a C program to multiply two numbers (4 and 5) and display its product.
4. Write a C program to calculate area and circumference of a circle.
5. Write a C program to perform addition, subtraction, division and
multiplication of two numbers.
6. Write C program to evaluate each of the following equations.
(i) V = u + at. (ii) S = ut+1/2a (iii) T=2*a+√b+9c

7. Write a program that reads an employee's number, his/her worked hours number in a
month and the amount he received per hour. Print the employee's number and salary
that he/she will receive at end of the month, with two decimal places.
8. Little John wants to calculate and show the amount of spent fuel liters on a trip, using
a car that does 12 Km/L. For this, he would like you to help him through a simple
program. To perform the calculation, you have to read spent time (in hours) and the
same average speed (km/h). In this way, you can get distance and then, calculate how
many liters would be needed. Show the value with three decimal places after the point.

You might also like