0% found this document useful (0 votes)
16 views12 pages

CBNST Lab

Uploaded by

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

CBNST Lab

Uploaded by

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

GRAPHIC ERA HILL

UNIVERSITY,
DEHRADUN

CBNST LAB MANUAL

Submitted to: Submitted by:


Mr. AYUSH MAHESHWARI ROHAN PAL

B. Tech CSE

Section: H2

Roll No: 50
DEPARTMENT OF B.Tech (CSE)
STUDENT LAB REPORT SHEET

Photograp
Name of Student ……………………………………….……. Mob.No……………………………….…………..
h Passport
Address Permanent ………………………………………………………………………………………….……….. Size
Father’s Name ………………………… Occupation …………………………… M.No……..…….….………
Mother’s Name …………………….. Occupation…………………………… M.No…………….…………..
Section ………… Branch…………………… Semester……………. Class Roll No...................Grade A B C
Local Address……………………………………………… Email.................................................Marks 5 3 1

S.N Practical D.O.P. Date of Grade Grade Total Student’s Teacher’s


o. Submiss (Viva) (Report Marks Signature Signature
ion File) (out of
10)
1 To deduce errors
(absolute error , relative
error , percentage error )
in a given program.
2 For given true value
finding the best
approximation value in a
given program.
3 To find the root of given
function using Bisection
method in a given
program.
4 To find the root of given
function using Iterative
method in a given
program.
5 To find the root of given
function using Secant
method in a given program.
6 To find the roots of an
algebraic equation using
Newton Raphson method.
7 Write a C Program to
implement Newton’s
backward Interpolation.
8 Write a C Program to
implement Newton’s
Forward Interpolation.
9 To find the real root of an
algebraic equation using
Gauss Elimination method.
10 To find the real root of an
algebraic equation using
Gauss Jordan method.
11

12

13

14
S.N Practical D.O.P. Date of Grade Grade Total Student’s Teacher’s
o. Submiss (Viva) (Report Marks Signature Signature
ion File) (out of
10)
15

16

17

18

19

20

Total No of Practical allotted ……………………………………….

Total No of Practical completed ………………………………….


Percentage Attendance of Practical …………………………….
Program
1
Name: Abhay

Bahuguna Roll

Number: 02 Section:

C2

Aim- To demonstrate the use of 10 mathematical functions from the ‘math.h’ library in C.

Algorithm: -

Step 1: Define the necessary libraries and constants:

•stdio.h for input/output operations

•math.h for mathematical functions

•M_PI constant for pi value

Step 2: Define the main function:

•Initialize variables:

➢ number to 16.0

➢ angle to M_PI / 4 (45 degrees in radians)

➢ base to 2.0

➢ exponent to 3.0

•Perform mathematical operations and print results:

1.Square root:

➢ Calculate square root of number using sqrt() function

➢ Print result

2.Power:

➢ Calculate base raised to the power of exponent using pow() function

➢ Print result

3.Sine:

➢ Calculate sine of angle using sin() function

➢ Print result

4.Cosine:

➢ Calculate cosine of angle using cos() function

➢ Print result

5.Tangent:

➢ Calculate tangent of angle using tan() function


➢ Print result

6.Logarithm base e (natural log):

➢ Calculate natural logarithm of number using log() function

➢ Print result

7.Logarithm base 10:

➢ Calculate logarithm base 10 of number using log10() function

➢ Print result

8.Exponential:

➢ Calculate exponential of number using exp() function

➢ Print result

9.Absolute value:

➢ Calculate absolute value of -5.0 using fabs() function

➢ Print result

10. Hyperbolic sine:

➢ Calculate hyperbolic sine of angle using sinh() function

➢ Print result

Step 3: Return 0 to indicate successful execution of the program.

Code: -

#include

<stdio.h>

#include

<math.h>

#ifndef M_PI

#define M_PI 3.14159265358979323846

#endif

int main() {

double number = 16.0;

double angle = M_PI / 4; // 45 degrees in

radians double base = 2.0;

double exponent = 3.0;

printf("Square root of %.2f is %.2f\n", number, sqrt(number));

printf("%.2f raised to the power of %.2f is %.2f\n", base, exponent,

pow(base, exponent));

printf("Sine of %.2f radians is %.2f\n", angle, sin(angle));


printf("Cosine of %.2f radians is %.2f\n", angle, cos(angle));

printf("Tangent of %.2f radians is %.2f\n", angle, tan(angle));

printf("Natural logarithm of %.2f is %.2f\n", number,

log(number)); printf("Logarithm base 10 of %.2f is %.2f\n",

number, log10(number)); printf("Exponential of %.2f is %.2f\n",

number, exp(number));

double negative_number = -5.0;

printf("Absolute value of %.2f is %.2f\n", negative_number,

fabs(negative_number));

printf("Hyperbolic sine of %.2f is %.2f\n", angle,

sinh(angle)); return 0;

Output: -
Program
2
Name: Abhay

Bahuguna Roll

Number: 02 Section:

C2

Program 2.1

Aim- To deduce an error (Absolute error, Relative error, Percentage error) in a given

problem. Algorithm

•Input true and approximate value from the user.

•Calculate Absolute error using formula- |real value-approximate value|

•Calculate Relative error using formula- | Absolute error / real value|

•Calculate Percentage error using formula- Relative error * 100

•Print all three errors with relevant messages.

Code:

#include

<stdio.h>

#include

<math.h> int

main(){

double appxValue =

1.414; double

trueValue;

printf("Enter the true value:

"); scanf("%lf",

&trueValue);

double absError = fabs(trueValue -

appxValue); printf("Absolute error is:

%.9lf \n", absError);

double relError = absError /

trueValue; double perError =

relError * 100.0;

printf("releative error is: %.9lf \n", relError);

printf("percentage error is: %.9lf \n",


perError);

Output:
Name: Abhay

Bahuguna Roll

Number: 02 Section:

C2

Program 2.2

Aim- Approximate value of 1/3 is 0.30, 0.33, 0.34 find the best approxima on

Algorithm:

•Take input of true value from the user

•Calculate Absolute error for each approximate value and print them

•Select the approximate value with lowest absolute error as best approximate value

•Print the best approximate value with relevant message.

Code:

#include<stdio

.h>

#include<math.

h> int main(){

double

appxValue1,appxValue2,appxValue3;

double trueValue =(1.0/3.0);

printf("Enter the 1st value:

"); scanf("%lf",

&appxValue1);

double absError1 = fabs(trueValue -

appxValue1); printf("Enter the 2nd value:

");

scanf("%lf", &appxValue2);

double absError2 = fabs(trueValue -

appxValue2); printf("Enter the 3rd value: ");

scanf("%lf", &appxValue3);

double absError3 = fabs(trueValue -

appxValue3); double mini =

absError1,miniElement = appxValue1;
if(absError1 > absError2){

mini = absError2;

miniElement =

appxValue2;

if(mini > absError3){


mini = absError3;

miniElement =

appxValue3;

printf("Nearest approx value is : %.2f with error: %.5lf",miniElement,mini);

Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy