BCSL-058 (2022-23) Solved Assignment
BCSL-058 (2022-23) Solved Assignment
com
Course Code : BŒL-058
Course Tltle : Computer orîented Numerlcal techniques Lab
Assignment Number : BCA(5)/L-058/Assignment/2022-23
Maximum Marks : id
Weightage : 25% vn/nv.lgnouske.com
Last Dates for Submlsslon : 31" October, 2022 (For July Session ••.•••@
: 15’ April. 2023 (fior January Session)
h
Q1. Write a program in CXC++ to find the solution of system of linear equations (given (8)
bclcw), by using Gaus‘x‘- Elimination methud:
z + y -F r = 2
x 2 y + 3a = 14
Q2. Writc a program in CXC++ to dctcrminc thc approximatc value ot thc definite intcpral (8)
(I) (given below), by usizig Siozpsoz's (J/3)rd mle:
1.D
I= x ’* 3 dx,
Q4. Write :t program in C/C++ to find the value of Sin(u/6) by using Lagrange's (8)
Interpolaiion, the related date is given below
0 z/4
y= Sin(x) 0 0.70711 1.0
Q5. Write a program in C/C to cnlcul tc the valuc of “cos z” by owing thc series (8)
expansion %ven below:
O0S/= 1--
2!+ + ...
4! 8!
for(j=11<=n+1;j++)
••a•*(°•¢*',^a[ill?]):
for(i=1;i<=n;i-i-+)
for(j=1;j<=n+1;j++)
printf("\t9L10.0f",a[i]|j]);
printf(“\n\n");
for(k=1;k<=n-1;k++)
if(a[k] k)==O.0)
printf("error“);
pivot = a[kjlkl;
for(j=k;j<=n+1;j++)
a[k]§]= a|k) §j/pivot;
for(i=k+1;i<=n;i++)
for(i-n-1;i>=1;i--)
sum = 0.0;
for(j=i+1;j•:=n;i**)
Sum = sum + a|ijȘj ” x|j];
[/]- ( [i]l +1] • )/ [i][il:
for(i=1;i<=n;i++)
printf("\n\tx %1d]=9610.4f“,i,x(i));
system("PAUSE”);
return 0;
return(1/ț1+x});
void main()
i nt i,n;
float x0,xn,h,y[20],so,se,ans,x[20]; printf("\
n Enter values of x0,xn, h: ");
scanf("96f96f%f‘,&X0,&xn,&h);
n=(xn-x0}/h;
if(n%2==1)
h=(xn-x0)/n;
printf("\n Refined value of n and h are:Kd %f\n",n.h);
printf("\n Y values: \n"j;
for(i=0; i<=n, i++)
x[i]=xD+i”h;
printf("\n %f\n”,y[i]);
sol;
se=0;
for(i=1; i<n; i++)
if(i%2==1)
else
se=se+y[i];
ans=h/3*(y[0]+y(n]+4*so+2‘se);
printf("\n Final integration ts %f",ans);
getch();
int n;
float a,b,h,x;
double f1,fZ,f0,FWDOp,BWDOP,CDOP,AVGOP;
/” CDOP — CENTRAL OIFFERENCE OPFRATOR ’/
cIrscr(T;
printf(“\n Enter the interval (a,b)”);
printf("\nEnter the value of a: ");
scanf{"%f",&a l;
printf("\nEnter the value of b: ");
scanf{"%f",&b);
printf(“\nEnter the number of nodes(n) In the interval (a,b): ”);
scanf{"%d”.&n);
h={b-a)/n; //STEP SIZE CALCULATION
printf("\nSTEP SIZE (h) =: 9âf”,h);
printf("\n VALUE OF POINT OF EVALUATION (X) ! ");
‹» t('!o f",s T;
CDOP = F(x+(h/2 }\ — F(x—(h/2});
printf(”\n RESULT OF CENTRAL DiFFERENCE OPEATOR = %f”,CDOP);
getch();
Ans.4
#include <cmath>
#incIude <iostream»
dinclude <iomanip>
using namespace std;
#define PI 3.1415
/fdefine N 12
int main()
// Declare and initialize two arrays to hold the coordinates of the Initial data points
double x[Nj, y[N];
// Generate the points
double xx = PI, step = 4 * PI / (N - 1);
for (int i = 0; i < N, ++i, xx += stepj
return 0;
#incIude <bits/stdc++.h>
using namespace std;
const double PI = 3.142;
double cosXSertiesSum(double x, Int n)
x = x ” (PI / 180.0);
double res = 1;
double sign = 1, fact = 1,
pow = 1;
for (int i = 1; i < 5; i++)
return res;
// Driver Code
int main()
float x = 50;
Int n = 5;
cout << cosXSertiesSum(x, 5);
return 0;