Lab Report Cse
Lab Report Cse
Code 1 :
#include<stdio.h>
int main ()
{
float a,b,c,d,e,f;
a=23;
b=5;
c=a+b;
d=a-b;
e=a*b;
f=a/b;
printf("sum=%f\n",c);
printf("sub=%f\n",d);
printf("product=%f\n",e);
printf("division=%f\n",f);
return 0;
}
Output :
Discussion: In this programme, I have used the arithmetic and logical operators.
Floating function used to declare variables for integer numbers and decimal
point . Then I had run some arithmetic operation by using the operators. Basic
arithmetic operators are used to perform Addition, Subtraction, Multiplication
& Division of two Numbers. There was no error in this experiment.
Experiment Number : 02
Experiment Name : Temperature conversion from Fahrenheit to Celsius.
Theory: Formula to convert temperature from degree Fahrenheit to degree
Celsius is given by -
Code 2:
#include<stdio.h>
int main()
{
float C,F;
F=100;
C=(F-32)*5/9;
printf("%f",C);
return 0;
}
Output:
Discussion: Floating function used to declare variables for integer numbers and
decimal.As there is no error in this code,the input value in Fahrenheit converted
into Celsius.
The above function fahrenheit_to_celsius() convert the temperature values
from Fahrenheit to Celsius.
And the function celsius_to_fahrenheit() will convert the temperature values
from Celsius to Fahrenheit.
The formula to convert Fahrenheit to Celsius we used here was:
temp_c = (temp_f -32) * 5/9. As there is no error in this code,the input value in
Fahrenheit converted into Celsius.
We will ask users to input two values for the variables a & b, respectively. Then
we pass those values through the swapping(a, b) function.
The values of both a and b are entered into the local variables of the
swapping(a, b) function, that is x and y, respectively.
Code 3:
#include<stdio.h>
int main()
{
float a,b,c;
a=56;
b=67;
c=a;
a=b;
b=c;
printf("%f\n",a);
printf("%f",b);
return 0;
}
Output:
Discussion: