CPNM-1@23
CPNM-1@23
First
Bachelor of Engineering
Year, First Semester Examination, 2023
Computer Programming and Numerical Methods
Time: 3 Hours
Full Marks: 100
B. Draw a flowchart to
accept numbers till the user enters 0 and then find their
C. Write average
an algurithm to print the first 100 prime numbers.
. Writo an algorithm to gonerate Fibonacci sorics of first rn terms wherè valuc of n is given as input.
2. Deteruine the
output of the following progran snippets. Iuclude brief justifications. Assune thst all
libraries lave been included and tliere is no uecessauy
syitax error. [Auswer Auy Eigl1t) S x 230
G
int main (){
i n t main(){
count;
int 0-(i0,15,-i,56,67,6,4
int 1, .
intp,qi
count-0;
Pa;
-o
f 0r( j - 3 ; j < - 3 ; J+*){ q-ta[o]+3;
( > 0 ) tk (i++)) printi("id\n", (*p) ++);
count count+j print ("a\a' (+*p));
printt ("d\n",«(--9):
count count+1; return 0;
printf ("Za\n", count);
return 0;
-L.
int zain (){
#define sQR(x) (x*x) int i-0;
#define sQR2 (x) ((x). (x)) while(i-2){
1 2 1
1 2 3 2 1
1 23 4 3 2 1
3a+20yz = 41
36
2x 3y+ 202 Bisection
three iterations of the
flæ) * +2:
= 3 +2 using Compute the
rclative error
after
[ Turn over
41
2x9 18
the polynomial
| 1.0 2.7 3.2 4.8
f(x)14.2 17.8 22.0 38.3
A. Write a C
paranieters:
slould have two Call the function
The function solution vector.
linear equations. r e t u n the nonlinear
matrix. The
function should
method to return
the root of a
angmented Newton-Raphson
of the root. Assume,
the
function for implementing
parameter as the initial guess
B. Write a C
one
should accept are:
0. The function defiued wlose prototypes
equation f(x) =
derivative f'(*)
are alreauly
and its
the functiou f(:)
double f (double x);
x);
double fd (double limits
function within
Call the function
from main (). integ1ration of a given
already defined
tlhat r e t u u s the (x) is
integrate(a, b,
h) the füuction f
method. Assunne,
Wiite a C function Trapezoidal
E. size h using
tlhe
a and b with a step
whose prototypo is
double f (double x);
Call the function from main0.