0% found this document useful (0 votes)
7 views4 pages

CPNM-1@23

This document outlines the examination paper for the First Bachelor of Engineering Year, covering topics in Computer Programming and Numerical Methods. It includes various questions requiring flowcharts, algorithms, C programming tasks, and numerical methods such as Gauss-Jordan and Newton-Raphson. The exam consists of multiple sections with specific tasks to be completed within a 3-hour timeframe.

Uploaded by

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

CPNM-1@23

This document outlines the examination paper for the First Bachelor of Engineering Year, covering topics in Computer Programming and Numerical Methods. It includes various questions requiring flowcharts, algorithms, C programming tasks, and numerical methods such as Gauss-Jordan and Newton-Raphson. The exam consists of multiple sections with specific tasks to be completed within a 3-hour timeframe.

Uploaded by

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

Ez/ES/CM/T104A/202

First
Bachelor of Engineering
Year, First Semester Examination, 2023
Computer Programming and Numerical Methods
Time: 3 Hours
Full Marks: 100

Answer All Questions


1. Answer Any Two.
2x 3= 6
A. Draw How chart to check whether
a
given As input.
a triangle is valid or not. Lengths of three sides of the triangle are

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

int main (){


int 1-1, j-1; 1 int func (int num) {
int count=0;
for(; ;
if (1>6) while (num) {
break; count
else nun> 1;
ji;
printf("%d\n", j) return(count);
it- int main(){
return 0; print ("xd\n", fune (435)):
1 11

void f(int *p, int *q){ 1 int main(){


int 1,j,x-0;
p2 for(i-0;i<5;*)
int i-0, j-1; for(j-0;j<i*
int main(){ x*(111)
break
(i, aj)
printf("d Zd\n", i, j); printf"Xd",a)
return 0;
return 0
1
int jumble (int x, int y){ Lat func(int zuz){
int count-0;
x-2x+y while (nun){
return x;
count++;
aumaum»>1;
int main (){
int x-2, y»5; return(count);
y-jumble (y,x);
-jumble (y,x); int main (){
printf("1d\n", x) printf("d\a", func (20)) ;
return 0:

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;

int Func (int x, int 7){

*s1, char *s2) { 1f((x-1)|I(7=1)D)


void fun1(char return 1;
chartmp; 1f (zy)
tmp s1; return X;
s1 s2 if (zy)
s2tmp return Func (x-y, y);
1! (y>x)
int nain (){ return unc(z, y-x);
"Hi", * s t r 2 " B y e " ;
char str1
funi(str1, str2); int cain (){
str2); 10));
printf("%s %s\n". str1, 13 print ("d\n", Pune (25,

-L.
int zain (){
#define sQR(x) (x*x) int i-0;
#define sQR2 (x) ((x). (x)) while(i-2){

int main(){ int i 1;


int a, b-2; i+
priat ("a\e", 1);
a-$QR(D2);
printf ("d \a", a);
printf("2d\n", SQR2 (a+b));
3
4x 7 28
3. Answer Any Four.
For cxamplc, the program
Write C program which takos an intoger n as input
a and prints a pattern.
should following patturn is printod whon n is 4.

1 2 1
1 2 3 2 1
1 23 4 3 2 1

, B. An Electricity board the following rates for


charges use of electricity.
For the Fist 200 unita: Rs 1 per unit
For tlie next 100 uuits: Rs 1.5 per unit
Beyond 300 units: Rs 2 Per unit.
amount.
Writc a C program to rcad numbor of unit consumcd and print out total chargo
.Consider the following structure definition:
struct student{
char name [40];
int roll1;
int marks [3];

10 stucdlents and store it in an


ancd marks in three subjects for
Write a C progran to accept name, roll and roll number of the student who has
student. Your program should print
the name
array of struct.
obtained the highest aggregate marks. toxt file and prints
in cach lino. Write a C program that roads that
D. A text flc storcs an integcr valuc
storcd in it.
maximun and minimum valuc *A, char *). Tho
function
two strings A and B: char *f(char
which accepts B after string A.
Writo a C function third string obtained by cuncutenating string
to hold a
'Do not use any string library
dynamically allocates memory function fron1 the main ().
return the tlird string. Call
The function should
matrix is upper triangular
function.
a n x n
matrix and check whether the
to read elements
in for the matrix dynamically.
F. Write a C program
iuput ad allocate meniory
should take n as
matrix or not. The
program 2 x 9 18

4: Answer Any Two. solve the following systen


of linear equations:
method method to
Gauss-Jordon or Jacobi
A. Use 18
20+y 2 2
=

3a+20yz = 41

36
2x 3y+ 202 Bisection
three iterations of the
flæ) * +2:
= 3 +2 using Compute the
rclative error
after

B . Determine the real


root of the equation
initial gucss of ai
=-5 and «5. =

Position method. Employ


or False
cach iteration.

cCCompute the valucs of


1+ the true
result with
your
with h = 0.25. Compare
Sinpson's rule
the Trapizoidal rule and 0.
g
valucs.
= t+,V0)
method, the cquation
and (b) Modifcd Eulor's
Euler's mothod
uSing (a)
Chooso h =0.2 and compute y(0.4) and y(0.6).

[ Turn over
41
2x9 18

Answer Auy Two. uethod. Also, fiud the value of


,
5 the followiug data usiug Lagraugiau's
iuterpolatiug
Fiud the polyuoiial
A. function at r 3.0.
=

the polynomial
| 1.0 2.7 3.2 4.8
f(x)14.2 17.8 22.0 38.3

to the following data.


inothod to fit & straight line
Usu linear regression
B.
f) 6 7 6 9 8 7 10
difference and
Newton's furw&rd
value of f(22) ancd f(42) usng
C. Given the folluwing
clatu, estimate the
difference formulae respectively.
bnckwarcd
40| 45
3 0 |35
20 25
f(x)354 332 291 260 231 204
he mocleled by
that such data can
below. It is known
the data tabulatecl linearize this equation
t r a n s f o r m a t i o n to
D. An investigator
has reportel Use a
ancd b are parameters.
the equation z
= e , where a determine a and b.
regreswion to
linear
nnd then employ
TI2 34 5
(x)0.5 |2 2.93.5
41
1x
10= 10

One. sulution of a set uf


Answer Any determining the
6 method
the G a u s s - J o r d o n
for
a [n] [n+1]
-
the
for implementing number of unknowns,
from main ().
function n -

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.

You might also like