Coding Based Question
Coding Based Question
57. Write a C program to calculate the volume of the following shapes: Cube,
Cuboid, Sphere,
Cylinder and Cone. Ask the user which one s/he wants to calculate, and take the
appropriate
required inputs. Then print the result. The input should be taken in the main
function and
calculations for every solid should be done in a separate function by passing
appropriate
arguments.
Example:
If the user chooses the option for cube, only one input is required i.e., the side.
The volume is
then calculated and printed.
If the user chooses the option for cuboid, only three inputs are required i.e.,
length, breadth and
height. The volume is then calculated and printed.
58. Write a C program to check if a number has three consecutive 5s. If yes,
print YES, else print NO.
Example:
Number: 1353554
Result: NO
Number: 345559
Result: YES
59. Write a C program to print the following pattern:
a) 1 b) 1
1222
123333
12344444
12 3 4 5 5 5 5 5 5
60. Write a C program to accept 10 values in an integer array. Display the
number of odd, even,
and negative numbers.
61. Write a C program to accept the basic salary of an employee from the user.
Calculate the gross
salary on the following basis:
Basic HRA DA
1 - 4000 10% 50%
4001 - 8000 20% 60%
8001 - 12000 25% 70%
12000 and above 30% 80%
62. Write a C function celsius() to convert degrees Fahrenheit to degrees
Celsius. (The
conversion formula is °C = 5/9 * (°F - 32).) Use it to print a Fahrenheit-to-
Centigrade table
for -40 to 220 degrees Fahrenheit, in increments of 10 degrees. (Remember that
%f is the
printf format to use for printing floating-point numbers. Also, remember that the
integer
expression 5/9 gives 0, so you won't want to use integer division.)
63. An Electricity board charges the following rates for use of electricity.
For the First 200 units : Rs 1 per unit
For the next 100 units : Rs 1.5 per unit
Beyond 300 units : Rs 2 Per unit.
Write a C Program to read no of unit consumed and print out total charge
amount.
64. Write a C program, which will print two digit numbers whose sum of both
digit is multiple of
seven.
e.g. 16,25,34......
65. Write a C program, That reads list of n integer and print sum of product of
consecutive
numbers.
if n=7 and numbers are 4,5,2,5,6,4,7
then output is 4*5+5*2+2*5+5*6+6*4+4*7 = 122.
66. Input date, month and year from the user, and using switch case, display in
worded format.
e.g.
input: d=16, m=7, y=1992
output: 16th July, 1992
67. Find out the ugly prime number
Desc: The given number is ugly prime number if it's prime factor
contains only among 2,3 or 5.
e.g. 20= 2*2*5 is ugly prime number
14=2*7 is not a ugly prime number
So write a C function which takes values from 1 to n and returns
the number of ugly primes number in it.
input: 20
output: 3