Engineering
- Write a program to find largest of n numbers taken from user. Answer: Store the n numbers in an array, take max = a[0] and replace it whenever a larger element is found. Logic: after one pass through th... 2
- Write recursive function to display factorial of an inputted number. Answer: factorial(n) returns 1 when n ≤ 1, otherwise n × factorial(n − 1). Logic: 5! = 5 × 4! = 5 × 4 × 3! = dots = 120. The base case n ≤ 1... 2
- Write a function to display n Fibonacci elements. Answer: A function fibonacci(n) starts with a = 0, b = 1 and repeatedly prints a and moves forward (c = a + b; a = b; b = c). Logic: each Fi... 2
- Write a program to demonstrate the use of break and continue branching structures. Answer: break exits the loop immediately; continue skips the remaining statements of the current iteration and goes to the next one. break:... 2
- Write a program to find LCM of two integer numbers. Answer: Find GCD by Euclid's method, then LCM = (a × b)/GCD. Logic (12, 18): 18 % 12 = 6, 12 % 6 = 0, so GCD = 6 and LCM = 12 × 18 / 6 = 36.... 2
- Write menu driven program to perform arithmetic calculations Answer: Show a menu, read the choice and use a switch statement for +, −, ×, ÷ inside a do-while loop until the user chooses Exit. Logic: ea... 2
- Write a program to check whether an inputted number is Armstrong or not. Answer: An n-digit number is Armstrong if the sum of each digit raised to the power n equals the number (e.g. 153 = 1³ + 5³ + 3³ ). Logic: f... 2
- Write a program to reverse digits of an imputed integer number. Answer: Repeatedly take the last digit (n % 10), append it to rev (rev = rev × 10 + digit) and drop it from n (n = n / 10). Logic (n = 123):... 2
- Write a program to check whether an inputted number is prime or not. Answer: A number n ≥ 2 is prime if no number from 2 to √(n) divides it. Logic: numbers less than 2 are not prime. Otherwise test divisors i... 2
- Write a program to compute sum of series. s = 1+ (1 / 2) + ( 1 / 3 )+ ( 1 / 4 )+ ( 1 / 5 )+………+ ( 1 / n ) Answer: Add 1.0/i for i = 1 to n; for the modified series keep a running factorial (fact = fact × i) and add 1.0/fact. Logic: Series 1: s =... 2
- Write a program to display patterns by accepting row number as an input. Pattern 1 1 1 2 1 2 3 Answer: Pattern 1 prints the column number j in row i; Pattern 2 (the modification) prints the row number i instead of j. Logic: the outer l... 2
- Write a program to find permutation and combination values. Answer: Use a factorial function: ⁿP_r = n!/((n-r)!) and ⁿC_r = n!/(r! (n-r)!). Logic: a function fact() returns n! using a loop. The progra... 2
- Write a program to check type of triangle and to evaluate its area. Answer: Check the triangle inequality, classify by comparing sides (equilateral/isosceles/scalene) and find area with Heron's formula. Logic... 2
- Write a program to compare two integer numbers using if-else statement Answer: Read two integers and compare them with an if – else if – else ladder. Logic: if a > b, a is greater; else if a < b, b is greater; o... 2
- Write a program to swap two inputted integer numbers using third variable without using third variable Answer: Swap with a temporary variable (t = a; a = b; b = t;) or without one (a = a + b; b = a - b; a = a - b;). Logic: Using a third variab... 2
- A cube 25 mm edge is placed centrally on the top of another square block of 40 mm edge and 15 mm thick. (i) Draw two isometric axes AB and AD of length 40 mm, each making an angle of 30° with the horizontal line. Draw BC and CD parallel to AD a... 1
- The front and top views of a straight line PQ measures 50 mm and 65 mm, respectively. Answer: True length of PQ ≈ 74 mm, θ (with H.P.) ≈ 28.5°, φ (with V.P.) ≈ 47.5°. HT coincides with p (20 mm in front of V.P.); VT is about 1... 1
- Draw the projections of following points on a common reference line keeping the distance between their Answer: Draw the reference line XY and four projectors 30 mm apart. For each point mark the front view (a′, b′ …) from the H.P. distance and... 1
- A line AB, 70mm long, has its end A 15mm above HP and 20mm in front of VP. Answer: Front view a′b′ = 49.5 mm at 45° to XY, top view ab = 60.6 mm at about 54.7° to XY, end projectors 35 mm apart; HT is about 1.2 mm b... 1
- The distance between the end projectors of a line AB is 40 mm. The end point A is 15 mm above HP and 20 m in from
- The F.V. and T.V. of a line AB measures 50 mm and 60 mm respectively. The line is 70 mm long.
- Draw a helix of pitch equal to 70 mm on a cylinder of 60 mm diameter Answer: Divide the circumference and the pitch into the same number of equal parts (say 12) and join the points where the matching projector... 1
- A wheel of 56 mm diameter rolls downwards on avertical wall for half revolution and then on the horizontal floor
- Explain the Dulong’s formula Answer: Dulong's formula gives the theoretical calorific value of a fuel from its percentage composition: HCV=1/100[8080 C+34500(H-O/8)+2240... 1