Professional Documents
Culture Documents
A. char < int < float B. int > char > float
C. char > int > float D. double > char > int
A. 5.38 B. 5.376666
C. 5 D. junk data
C. 5 D. junk data
A. 5.38 B. 5.376666
C. 5 D. junk data
A. 2 B. 1.666667 C. 1 D. -2
12. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. int i = -5;
5. int j = i % 3;
6. printf("%d\n", j);
7. }
A. 2 B. 1.666667 C. 1 D. -2
13. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. int i = 5;
5. int j = i / 3;
6. printf("%d\n", j);
7. }
A. 2 B. 1.666667 C. 1 D. -2
14. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. float i = 5.0;
5. float j = i / 3.0;
6. printf("%f\n", j);
7. }
A. 2 B. 1.666667 C. 1 D. -2
15. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. float i = 5.0;
5. int j = i / 3;
6. printf("%d\n", j);
7. }
A. 2 B. 1.666667 C. 1 D. -2
16. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. int i = 5;
5. int j = i % -3;
6. printf("%d\n", j);
7. }
A. 2 B. 1.666667 C. 1 D. -2
17. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. int i = 8 * 2 + 4 * 5 / 2;
5. printf("%d\n", j);
6. }
A. 120 B. 26 C. 50 D. 88
A. 120 B. 26 C. 50 D. 88
19. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. int i = 8 * (2 + 4) * 5 / 2;
5. printf("%d\n", j);
6. }
A. 120 B. 26 C. 50 D. 88
1. #include <stdio.h>
2. int main()
3. {
4. int i = 8 * 2 + (4 * 5) / 2;
5. printf("%d\n", j);
6. }
A. 120 B. 26 C. 50 D. 88
1. #include <stdio.h>
2. int main()
3. {
4. int i = 8 * (2 + 4 * 5) / 2;
5. printf("%d\n", j);
6. }
A. 120 B. 26 C. 50 D. 88
1. #include <stdio.h>
2. int main()
3. {
4. int a = 5, b = 2;
5. int c = 2 * (a++) + (b--);
5. printf("%d\n", c);
6. }
A. 11 B. 12 C. 13 D. 14
23. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. int a = 5, b = 2;
5. int c = 2 * (++a) + (b--);
5. printf("%d\n", c);
6. }
A. 11 B. 12 C. 13 D. 14
1. #include <stdio.h>
2. int main()
3. {
4. int a = 5, b = 2;
5. int c = 2 * (++a) + (--b);
5. printf("%d\n", c);
6. }
A. 11 B. 12 C. 13 D. 14
1. #include <stdio.h>
2. int main()
3. {
4. int a = 5, b = 2;
5. int c = 2 * (a++) + (--b);
5. printf("%d\n", c);
6. }
A. 11 B. 12 C. 13 D. 14
A. %, *, /, +, - B. %, +, /, *, -
C. +, -, %, *, / D. %, +, -, *, /
A. x += 5 B. x *= 5
C. x %= 5 D. x != 5
28. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. int a = 1;
5. if (a = 1) printf("Yes\n");
6. else printf("No\n");
7. }
A. Yes B. No
C. Error
A. Yes B. No
C. Error
1. #include <stdio.h>
2. int main()
3. {
4. int a = 0;
5. if (a = 0) printf("Yes\n");
6. else printf("No\n");
7. }
A. Yes B. No
C. Error
1. #include <stdio.h>
2. int main()
3. {
4. int a = 0;
5. if (a == 0) printf("Yes\n");
6. else printf("No\n");
7. }
A. Yes B. No
C. Error
32. What will be the output of the following code?
1. #include <stdio.h>
2. int main()
3. {
4. int a == 0;
5. if (a == 0) printf("Yes\n");
6. else printf("No\n");
7. }
A. Yes B. No
C. Error
1. #include <stdio.h>
2. int main()
3. {
4. int x = 5, y = 5;
5. if (x == 10) y--;
6. printf("%d, %d", x, y--);
7. }
A. 5, 5 B. 5, 4
C. 10, 3 D. 10, 4
1. #include <stdio.h>
2. int main()
3. {
4. int x = 5, y = 5;
5. if (x = 10) y--;
6. printf("%d, %d", x, y--);
7. }
A. 5, 5 B. 5, 4
C. 10, 3 D. 10, 4
1. #include <stdio.h>
2. int main()
3. {
4. int x = 5, y = 5;
5. if (x = 10) y--;
6. printf("%d, %d", x, --y);
7. }
A. 5, 5 B. 5, 4
C. 10, 3 D. 10, 4
1. #include <stdio.h>
2. int main()
3. {
4. int x = 5, y = 5;
5. if (x == 10) y--;
6. printf("%d, %d", x, --y);
7. }
A. 5, 5 B. 5, 4
C. 10, 3 D. 10, 4
1. #include <stdio.h>
2. int main()
3. {
4. int x = 5, y = 5;
5. if (x == 5) y--;
6. printf("%d, %d", x, y--);
7. }
A. 5, 5 B. 5, 4
C. 10, 3 D. 10, 4
38. The expression ‘break’ isn't used within:
A. do-while B. if-else
C. for D. while
39. Which expression is used to come out of a loop only for that iteration?
A. break B. continue
C. exit () D. return
A. break B. continue
C. exit () D. return
A. break B. continue
C. exit () D. return
A. break B. continue
C. exit () D. return
43. How many times will the program print "Hello" at the screen?
1. #include <stdio.h>
2. int main()
3. {
4. int i, j;
5. for (i=0; i<3; i++)
6. {
7. for (j=0; j<3; j++)
8. {
9. printf("Hello\n");
10. if (i>1) break;
11. }
12. }
13. }
A. 3 B. 6 C. 7 D. 9
44. How many times will the program print "Hello" at the screen?
1. #include <stdio.h>
2. int main()
3. {
4. int i, j;
5. for (i=0; i<3; i++)
6. {
7. for (j=0; j<3; j++)
8. {
9. if (i>1) break;
10. printf("Hello\n");
11. }
12. }
13. }
A. 3 B. 6 C. 7 D. 9
45. How many times will the program print "Hello" at the screen?
1. #include <stdio.h>
2. int main()
3. {
4. int i, j;
5. for (i=0; i<3; i++)
6. {
7. for (j=0; j<3; j++)
8. {
9. printf("Hello\n");
10. }
11. if (i>1) break;
12. }
13. }
A. 3 B. 6 C. 7 D. 9
46. How many times will the program print "Hello" at the screen?
1. #include <stdio.h>
2. int main()
3. {
4. int i, j;
5. for (i=0; i<3; i++)
6. {
7. for (j=0; j<3; j++)
8. {
9. if (i>1) break;
10. }
11. printf("Hello\n");
12. }
13. }
A. 3 B. 6 C. 7 D. 9
47. How many times will the program print "Hello" at the screen?
1. #include <stdio.h>
2. int main()
3. {
4. int i, j;
5. for (i=0; i<3; i++)
6. {
7. for (j=0; j<3; j++)
8. {
9. printf("Hello\n");
10. if (i>1) continue;
11. }
12. }
13. }
A. 3 B. 6 C. 7 D. 9
A. Yes B. No C. Sometimes
B) Evaluate the following integrals:
𝜋
i. ∫0 sin 𝑥 𝑑𝑥
2 (h = π / 4)
𝜋
ii. ∫02 cos 𝑥 𝑑𝑥 (h = π / 4)
51
iii. ∫0 𝑑𝑥 (h = 2.5)
𝑥
C) Resolve the previous problem numerically using Simpson's 1/3 rule and
write a proper C code to solve the integrations.
H) The steady state 1-dimensional heat equation, with no heat generation is:
𝑑2𝑇
= 𝑍𝑒𝑟𝑜
𝑑𝑥 2
Use the equation to calculate the temperature distribution with in a solid slab
of length L =1 m and thermal conductivity k. Solve the problem analytically
and numerically (using finite difference technique) and compare the results.
Then, write a c programming code to solve the problem, for each of the
following cases.
a) T1 = 50°C & T2 = 30°C.
b) T1 = 70°C & T2 = 20°C.
c) T1 = 35°C & T2 = 30°C.
d) T1 = 20°C & T2 = 65°C.
e) T1 = 25°C & T2 = 80°C.
I) The steady state 2-dimensional heat equation, with no heat generation is:
𝑑2 𝑇 𝑑2 𝑇
+ = 𝑍𝑒𝑟𝑜
𝑑𝑥 2 𝑑𝑦 2
T1
a
T3
T2
J) Solve analytically and numerically:
a) 𝑦̀ = 4y + 2, y(0) = 5.
b) 𝑦̀ = 6y + 1, y(0) = 1.
c) 𝑦̀ = −3y + 5, y(0) = 1.
d) 𝑦̀ = 2y + 3, y(0) = 1.
e) 𝑦̀ = −3y + 1, y(0) = 1.
a) Solve analytically to get the exact solution to the previous ODEs.
b) Solve numerically using Euler approach from x=0 to x=1 with step
size h=0.5, and write the appropriate programming code.
c) Solve numerically using Rung-Kutta approach from x=0 to x=1
with step size h=0.5, and write the appropriate programming code.
d) compare the results with the exact solution.
K) By the least squares method find the value of the constants a, b that satisfies
the following equations for the data given in the table and write a C program
to evaluate these constants.
x 0.5 1 2 3
y 4 6 10 8
a) 𝑦 = 𝑎. 𝑥 + 𝑏
b) 𝑦 = 𝑎. 𝑥𝑦 + 𝑏
c) 𝑦 = 𝑏. 𝑒 𝑎𝑥
d) 𝑦 = 𝑏. 𝑥 𝑎
e) 𝑦 = 𝑙𝑛(𝑏. 𝑥)𝑎