C-program-Code-practice-Questions
C-program-Code-practice-Questions
1. Write a program to calculate the nth Fibonacci number using an arithmetic formula.
5
52. Write a program to check if the sum of digits of a number is divisible by 3.
53. Write a program to calculate the perimeter of a triangle (a + b + c).
54. Write a program to convert kilometers to miles.
55. Write a program to convert grams to kilograms.
56. Write a program to convert minutes to seconds.
57. Write a program to calculate the average of three floating-point numbers.
58. Write a program to calculate the weighted average of three numbers.
59. Write a program to compute the area of a right triangle given base and height.
60. Write a program to calculate the volume of a cylinder (π × radius² × height).
61. Write a program to calculate the surface area of a sphere (4 × π × radius²).
62. Write a program to calculate the area of a trapezoid.
3. Write a program to calculate the total cost of an item after applying a discount.
6
64. Write a program to calculate the time required to travel a given distance at a given speed.
65. Write a program to check whether a year is a leap year or not.
66. Write a program to calculate the area of a parallelogram.
67. Write a program to calculate the area of a rhombus.
68. Write a program to calculate the profit or loss after buying and selling a product.
69. Write a program to calculate the cost of painting a rectangular room.
70. Write a program to calculate the monthly salary of an employee after tax deductions.
71. Write a program to calculate the profit percentage from cost and selling price.
72. Write a program to calculate the discounted price of an item after applying a given percentage
discount.
73. Write a program to convert a given time in seconds to hours, minutes, and seconds.
74. Write a program to find the area of a sector of a circle (θ × π × radius² / 360).
75. Write a program to compute the length of the hypotenuse of a right triangle using Pythagoras
theorem.
76. Write a program to compute the average speed for a journey when distances and times are
given.
77. Write a program to calculate the sum of cubes of the first n natural numbers.
78. Write a program to compute the roots of a quadratic equation using the quadratic formula.
79. Write a program to calculate the area of an ellipse (π × a × b).
80. Write a program to calculate the surface area of a cone (π × radius × (radius + slant height)).
81. Write a program to compute the volume of a rectangular prism.
82. Write a program to find the sum of cubes of the digits of a number.
83. Write a program to find the product of digits of a number.
84. Write a program to compute the harmonic sum of n terms.
85. Write a program to calculate the number of days between two dates.
86. Write a program to find the greatest common divisor (GCD) of two numbers.
87. Write a program to find the least common multiple (LCM) of two numbers.
88. Write a program to calculate the sum of the digits of a number recursively.
89. Write a program to calculate the sum of cubes of even numbers between 1 and n.
90. Write a program to calculate the sum of cubes of odd numbers between 1 and n.
91. Write a program to check if a number is prime and calculate its sum of digits.
92. Write a program to find the reverse of a given number.
93. Write a program to count how many times a digit appears in a given number.
94. Write a program to check if a number is an Armstrong number.
95. Write a program to calculate the average of the digits of a number.
96. Write a program to find the product of all even digits in a number.
97. Write a program to find the smallest prime factor of a number.
98. Write a program to find the sum of all prime numbers up to a given number.
99. Write a program to find the factorial of a number without using recursion.
100. Write a program to check if a number is a perfect square.
Multidimensional Arrays
rite a program to declare and initialize a 2D array with 3 rows and 3 columns.
W
Write a program to print a 2D array.
Write a program to find the sum of all elements in a 2D array.
Write a program to find the largest element in a 2D array.
Write a program to find the smallest element in a 2D array.
Write a program to find the sum of each row in a 2D array.
Write a program to find the sum of each column in a 2D array.
Write a program to find the transpose of a 2D array.
Write a program to check if two 2D arrays are equal.
Write a program to multiply two matrices (2D arrays).
Write a program to add two matrices (2D arrays).
Write a program to perform matrix subtraction (2D arrays).
Write a program to rotate a matrix 90 degrees clockwise.
Write a program to rotate a matrix 90 degrees counterclockwise.
Write a program to print a matrix in spiral order.
Write a program to find the trace of a square matrix.
Write a program to find the determinant of a 2x2 matrix.
Write a program to check if a 2D array is symmetric (i.e., equal to its transpose).
Write a program to calculate the row-wise sum and column-wise sum of a 2D array.
Write a program to search for an element in a 2D array.
Advanced Array Operations: