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

Doc2

The document contains a series of lab reports detailing C programming experiments, including calculating the area and perimeter of geometric shapes (rectangle, circle, triangle), adding three numbers, and converting temperatures between Celsius and Fahrenheit. Each report outlines the objective, required software, algorithm, source code, and expected output. The experiments aim to enhance programming skills and understanding of basic mathematical concepts using C.

Uploaded by

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

Doc2

The document contains a series of lab reports detailing C programming experiments, including calculating the area and perimeter of geometric shapes (rectangle, circle, triangle), adding three numbers, and converting temperatures between Celsius and Fahrenheit. Each report outlines the objective, required software, algorithm, source code, and expected output. The experiments aim to enhance programming skills and understanding of basic mathematical concepts using C.

Uploaded by

chandankhulna84
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Lab Report 01

Experiment Name:
Calculating area and perimeter of a rectangle in C.

Objective:

To write a C program that calculates and displays the area and perimeter of a rectangle,
taking the length and width as input from the user.

Software Required

 Computer system
 C compiler (GCC, Turbo C++)
 Text editor (Notepad++, Visual Studio Code, Codeblocks)

Flow Chart
Algorithm:

Step 1: Start.

Step 2: Declare Variables.

Step 3: Read the length and width of the rectangle.

Step 4: Calculate the area of rectangle

area = length*width;

Step 5: Calculate the perimeter of rectangle

perimeter = 2*(length + width);

Step 6: Print the area and perimeter.

Step 7: End.
Source code:
#include <stdio.h>

int main() {

int length, width, area, perimeter;

printf("Enter the length of the rectangle: ");

scanf("%d", &length);

printf("Enter the width of the rectangle: ");

scanf("%d", &width);

area = length * width;

perimeter = 2 * (length + width);

printf("Area of the rectangle: %d square

units\n", area);

printf("Perimeter of the rectangle: %d

units\n", perimeter);

return 0;

}
Output:
Lab Report 02

Experiment Name:

Finding Area and Circumference of a Circle.

Objective:

To write a C program that calculates the area and circumference of a circle using a
symbolic constant for the value of pi.

Software Required:

 Computer system
 C compiler (GCC, Turbo C++)
 Text editor (Notepad++, Visual Studio Code, Codeblocks)
Algorithm:

Step 1: Start.

Step 2: Declare Variables.

Step 3: Read the radius of a circle.

Step 4: Calculate the area of circle

area=PI*radius*radius;

Step 5: Calculate the circumference of circle

circumference = 2*PI*radius

Step 6: Print the area and circumference.

Step 7: End.

Source code:
#include <stdio.h>
#define PI 3.1416

int main() {
float radius, area, circumference;

printf("Enter the radius of the circle: ");


scanf("%f", &radius);

area = PI * radius * radius;


circumference = 2 * PI * radius;

printf("Area of the circle = %.2f sq units\n", area);


printf("Circumference of the circle = %.2f units\n",
circumference);
return 0;
}
Output:
Lab Report 03

Experiment Name:

Finding Area and Circumference of a triangle.

Objective:

To write a C program that calculates the area and circumference of a triangle using the
given three sides of the triangle.

Software Required:

 Computer system
 C compiler (GCC, Turbo C++)
 Text editor (Notepad++, Visual Studio Code, Codeblocks)
Algorithm:

Step 1: Start.

Step 2: Declare Variables.

Step 3: Read the three sides of a triangle.

Step 4: Calculate the semi-perimeter of the triangle

s = (side1 + side2 + side3) / 2;

Step 5: Calculate the area using Heron's formula

area = sqrt(s * (s - side1) * (s - side2) 1 * (s - side3));

Step 6: Calculate the perimeter of triangle

perimeter = side1 + side2 + side3;

Step 7: Print the area and perimeter.

Step 8: End.
Source code:
#include <stdio.h>

#include <math.h>

int main() {
float side1, side2, side3, s, area, perimeter;

printf("Enter the three sides of the triangle: ");


scanf("%f %f %f", &side1, &side2, &side3);

// Calculate the semi-perimeter


s = (side1 + side2 + side3) / 2;

// Calculate the area using Heron's formula


area = sqrt(s * (s - side1) * (s - side2) * (s - side3));

// Calculate the perimeter


perimeter = side1 + side2 + side3;

printf("Area of the triangle = %.2f sq units\n", area);


printf("Perimeter of the triangle = %.2f units\n", perimeter);
return 0;
}
Output:
Lab Report 04

Experiment Name:

Addition of Three Numbers in C.

Objective:

To write, compile, and execute a C program to calculate the sum of three numbers
entered by the user.

Software Required:

 Computer system
 C compiler (GCC, Turbo C++)
 Text editor (Notepad++, Visual Studio Code, Codeblocks)
Algorithm:

Step 1: Start.

Step 2: Declare Variables.

Step 3: Read the three numbers.

Step 4: Calculate the sum of the three numbers

sum = num1 + num2 + num3;

Step 5: Print the sum.

Step 6: End.

Source code:
#include <stdio.h>

int main() {

int num1, num2, num3, sum;

printf("Enter three numbers: ");

scanf("%d %d %d", &num1, &num2, &num3);

sum = num1 + num2 + num3;

printf("Sum of the numbers = %d\n", sum);

return 0;

}
Output:
Lab Report 05

Experiment Name:

Celsius to Fahrenheit Conversion Using C Programming.

Objective:

To write and execute a C program that converts a given temperature in Celsius to its
equivalent value in Fahrenheit.

Software Required:

 Computer system
 C compiler (GCC, Turbo C++)
 Text editor (Notepad++, Visual Studio Code, Codeblocks)
Algorithm:

Step 1: Start.

Step 2: Declare Variables.

Step 3: Read the celsius temperature .

Step 4: Convert the celsius temperature to fahrenheit.

fahrenheit = (celsius * 9 / 5) + 32;

Step 5: Print the fahrenheit temperature.

Step 6: End.

Source code:
#include <stdio.h>

#include <stdio.h>

int main() {

float celsius, fahrenheit;

printf("Enter temperature in Celsius: ");

scanf("%f", &celsius);

fahrenheit = (celsius * 9 / 5) + 32;

printf("%.2f degree Celsius = %.2f degree Fahrenheit \n", celsius, fahrenheit);

return 0;

}
Output:
Lab Report 06

Experiment Name:

Celsius to Fahrenheit Conversion Using C Programming.

Objective:

To write and execute a C program that converts a given temperature in Celsius to its
equivalent value in Fahrenheit.

Software Required:

 Computer system
 C compiler (GCC, Turbo C++)
 Text editor (Notepad++, Visual Studio Code, Codeblocks)
Algorithm:

Step 1: Start.

Step 2: Declare Variables.

Step 3: Read the fahrenheit temperature .

Step 4: Convert the fahrenheit temperature to celsius.

celsius = (fahrenheit - 32) * 5 / 9;

Step 5: Print the celsius temperature .

Step 6: End.

Source code:
#include <stdio.h>

int main() {

float fahrenheit, celsius;

printf("Enter temperature in Fahrenheit: ");

scanf("%f", &fahrenheit);

celsius = (fahrenheit - 32) * 5 / 9;

printf("%.2f degree Fahrenheit = %.2f degree Celsius", fahrenheit, celsius);

return 0;

}
Output:

You might also like