You are on page 1of 5

Lab Report 2

Objective:
 To convert the temperature from Celsius to Fahrenheit.
 To compute & display the value of X.
 To evaluate the Area of the Triangle.

Description:
Program-1
Initialized three floating variables temp, F & c. Then take a value of temperature in Celsius
scale. Then apply formula to convert the temperature to Fahrenheit i.e. F = 9 * c / 5 + 32. Now
value of temperature in Celsius scale are multiply by 9 and the final product is divided by 5.
Then the quotient is assigned to variable a. Then the value of temp + 32 is assigned to variable
F. After assigning we print the value of F in Fahrenheit Scale. It is the final result of this
program.
Program-2
Declared four variables are named a, b , c & x. Then take the value of three variables a, b & c.
Then apply the formula x = a / (b-c).Now value of a is divided by value of (b-c) then it’s assigned
to variable x. Finally we print the value of x for the result.
Program-3
Declared five variables a, b, c, S & A. Then take the values of a, b & c. After taking values then
the total sum of (a+b+c) is divided by 2 & the quotient is assigned to variable S. Then the value
of sqrt(s*(s-a)*(s-b)*(s-c)) are assigned to variable A. Finally we print the value of A which are
the area of triangle.
Source Code: (Program-1)
/* write a c program to print temperature in Fahrenheit scale */
#include<stdio.h>
int main()
{
float temp,F,c;

printf("Enter temperature in celsius: ");


scanf("%f",&c);

temp=(9*c)/5;
F=temp+32;

printf("\nIn Fahrenheit scale=%.2f",F);

return 0;
}

Input/Output:
Program-1
Source Code: (Program-2)
/* write a c program to display the value of x */
#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,x;
printf("Enter the three numbers a, b & c: ");
scanf("%f %f %f",&a,&b,&c);
x=a/(b-c);
printf("The Result=%.2f",x);
return 0;
}

Input/Output:
Program-2
Source Code: (Program-3)
/* write a c program to find out area of triangle */
#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,S,A;
printf("Enter the value of 1st side a: ");
scanf("%f", &a);
printf("Enter the value of 1st side b: ");
scanf("%f", &b);
printf("Enter the value of 1st side c: ");
scanf("%f", &c);
S= (a+b+c)/2;
A=sqrt(S*(S-a)*(S-b)*(S-c));
printf("The area of the triangle: %.2f\n",A);
return 0;
}

Input/Output:
Program-3
Discussion:
In first program we learn how to convert the temperature from Celsius to
Fahrenheit. This program convert the temperature in Celsius scale to Fahrenheit
scale.
In second program we compute & display the value of X. This program help us to
compute and display the value of X.
In third program we learn how to evaluate the area of triangle. Using this program
we can find out area of a triangle.

You might also like