→ Lab Session 1←
int i, n, exp;
float x, sum = 1, t = 1 ;
printf(“Enter the value for x : “) ;
scanf(“%f”, &x) ;
printf(“\nEnter the value for n : “) ;
scanf(“%d”, &n) ;
for(i = 1 ; i < n + 1 ; i++)
exp = i ;
t = t * x / exp ;
sum = sum + t ;
printf(“\nExponential Value of %f is : %8.4f”, x, sum) ;
2) Write program to calculate the approximate value of Sine of a value given in radians. Compare the value obtained by you with actual values. Explain, if you find the difference between the two. The Sine can be defined using the formula :
Solution: click to display solution
3) Write a program that accepts a decimal number and displays its floating point equivalent number. You may make assumptions to simplify the program, however, your representation of floating point number should be closer to IEEE 754 standard 32 bit representation.
→ Lab Session 2←
1) Write a program to implement Gauss Elimination method for solving linear equations. Your method should check if a given pivot is zero or not. It should also minimise the floating point errors.
2) Write a program to implement Gauss Seidel method for finding the roots of linear equations.
3) Distance covered by an object can be represented by the equation:
s(t)=x_1+x_2 t+x_3 t^2
The object distance was observed in the time interval. The following table shows these observations:
Time (t) in seconds Distance (s) in meters
Create the system of linear equations using the data given in the table. Solve it using any program that you have created (in problem 1 or 2) for this purpose.