Bachelor of Engineering First Year First Semester Examination, 2019 Computer Programming & Numerical Methods
Bachelor of Engineering First Year First Semester Examination, 2019 Computer Programming & Numerical Methods
Bachelor of Engineering First Year First Semester Examination, 2019 Computer Programming & Numerical Methods
Ex/ES/CM/T104A/2019
A. Draw a flow chart to print the reverse of a positive integer read as input.
B. Draw a flow chart for finding out whether a given positive integer is prime or not.
C. Draw a flow chart for finding the product of individual digits of a positive integer
read as input.
D. Draw a flow chart for finding the distance between two points given as input.
2. Determine the output of the following program snippets. Include brief justifications.
[Answer any ten]
10x2=20
A main(){ B main(){
int i=5, j=2; int a, b=10;
float a, b=2, c; a=(b>5)?b++:b--;
a=i/j; printf("%d %d\n", a, b);
c=i/b; }
printf("%f %f\n", a, c);
}
C main(){ D main(){
int i; int a=2, b=3, c=1;
int j=0;
printf("%d\n", a<<1+b);
for(i=0; i<50;i++){ printf("%d\n", a+b>>c>2);
if(i%7==0) }
j++;
}
printf("%d\n", j);
}
E main(){ F main(){
int i, j, k=1; int i, n;
char *x = "India";
for(i=1;i<=3;i++){
for(j=1;j<=i;k += i,j++) n=strlen(x);
printf("%d ", k); *x = x[n];
printf("\n"); for(i=0; i‹n; i++){
} printf("%s\n",x);
} x++;
}
}
G main(){ H void test(void){
unsigned char i = 127; static int j;
char j=i+1; j++;
printf("%d\n", j);
printf("%d\n", j); }
} main(){
test();
test();
}
I main(){ J main(){
int i=5; int i=5; j=2;
printf("%d %d", i>>1); printf("%d %d %d", i|j, i&j, i^j);
printf("%d %d", i<<2); }
}
A. Find the second (at the end of 2 iterations) iterative value of the root of 𝑥 3 − 3𝑥 2 +
5 = 0 in the domain of 𝑥 ∈ [1, 5] using Bisection OR False-Position method.
C. A jet fighter’s position on an aircraft carrier’s runway was timed during landing.
where, 𝑦 is the distance of the jet fighter from the end of the runway. Estimate the
𝑑𝑦
velocity at (i) 𝑡 = 1.1, (ii) 𝑡 = 1.6 using Newton’s Forward Difference formula.
𝑑𝑡
D. A ball at 1200K is allowed to cool down in air. Assuming heat is lost only due to
radiation, the differential equation for the temperature of the ball (𝜃 in K) is given by
𝑑𝜃
= −2.2067 × 10−12 (𝜃 4 − 81 × 108 )
𝑑𝑡
Find the temperature of the ball at 𝑡 = 480 second using Euler’s method. Assume,
𝜃(0) = 1200𝐾 and a step size of ℎ = 240 seconds.
𝑣(𝑡) = 2𝑡, 1 ≤ 𝑡 ≤ 5
𝑣(𝑡) = 5𝑡 2 + 3, 5 < 𝑡 ≤ 14
where, 𝑡 is given in seconds, and 𝑣 is given in m/s. Using 2-segment Simpson’s 1/3rd
Rule OR Trapezoidal Method, find the distance covered by the body from 2 to 9
seconds.
A. Use the method of least squares to fit a quadratic curve through the following data:
𝑥 0 5 10 15 20
𝑓(𝑥) 7 11 16 20 26
Find the pressure at temperature 152 °C using Newton's Forward Difference method.
C. Find the values of 𝑎, 𝑏 and 𝑐 so that 𝑌 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2 is the best fit to the data.
𝑥 0 1 2 3 4
𝑦 1 0 3 10 21
D. An experiment on the life of a cutting tool at different cutting speeds gave the
following values:
It is known that 𝑣 and 𝑇 satisfy the relationship 𝑣 = 𝑎𝑇 𝑏 . Using the method of least
squares find the best values of 𝑎 and 𝑏.
Note: (i) Two Real Numbers may be considered equal if their absolute difference is less than
10-6], (ii) Input/Output should be handled in main()
--------|--------