Question Bank C
Question Bank C
C PROGRAMMING
1. Write a program that prints the message "Hello, world!" to the console.
2. Write a program that takes two integers as input and prints their sum to the console.
3. Write a program that takes an integer as input and prints whether it is even or odd.
4. Write a program that takes a string as input and prints each character of the string on a new
line.
5. Write a program that takes an integer as input and prints all the prime numbers that are less
than or equal to it.
6. Write a program that takes an integer as input and prints the factorial of that integer.
7. Write a program that takes an integer as input and prints the nth number in the Fibonacci
sequence.
8. Write a program that takes an integer as input and prints all the divisors of that integer.
9. Write a program that takes an integer as input and checks whether it is a palindrome.
10. Write a program that takes two integers as input and prints their greatest common divisor.
11. Write a program that takes a list of integers as input and prints the sum of all the even
numbers in the list.
12. Write a program that takes a list of integers as input and prints the maximum and minimum
values in the list.
13. Write a program that takes a list of integers as input and prints a new list containing only the
positive integers.
14. Write a program that takes a list of strings as input and prints a new list containing only the
strings that have a length of more than five characters.
15. Write a program that takes a string as input and prints the reverse of the string.
16. Write a program that takes an integer as input and prints a right triangle of asterisks of
height n.
17. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are divisible by 3.
18. Write a program that takes a list of integers as input and returns the product of all the
numbers in the list.
19. Write a program that takes a list of integers as input and returns the index of the first
occurrence of the number 7 in the list.
20. Write a program that takes a list of integers as input and returns the second largest number
in the list.
21. Write a program that takes a list of integers as input and returns the number of elements in
the list.
22. Write a program that takes a list of integers as input and returns the sum of all the numbers
that are greater than or equal to 10.
23. Write a program that takes a list of integers as input and returns a new list containing the
squares of all the numbers in the original list.
24. Write a program that takes an integer as input and prints a pyramid of asterisks of height n.
25. Write a program that takes a list of integers as input and returns the sum of all the prime
numbers in the list.
26. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are even.
27. Write a program that takes a list of integers as input and returns the median value of the list.
28. Write a program that takes a list of integers as input and returns the index of the largest
number in the list.
29. Write a program that takes a list of integers as input and returns the number of occurrences
of the number 7 in the list.
30. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are less than or equal to 5.
31. Write a program that takes two integers as input and returns the product of those two
numbers.
32. Write a program that takes a list of integers as input and returns the sum of all the numbers
that are less than 10.
33. Write a program that takes a list of integers as input and returns the number of prime
numbers in the list.
34. Write a program that takes a list of strings as input and returns a new list containing only the
strings that start with the letter 'A'.
35. Write a program that takes a list of integers as input and returns the average of the numbers
in the list.
36. Write a program that takes a string as input and returns the number of vowels in the string.
37. Write a program that takes a list of integers as input and returns the number of numbers in
the list that are greater than the average of the numbers in the list.
38. Write a program that takes a list of integers as input and returns a new list containing the
absolute values of all the numbers in the original list.
39. Write a program that takes a list of integers as input and returns the second smallest number
in the list.
40. Write a program that takes a list of integers as input and returns the difference between the
largest and smallest numbers in the list.
41. Write a program that takes a list of integers as input and returns the sum of the squares of all
the numbers in the list.
42. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are perfect squares.
43. Write a program that takes a string as input and returns the number of words in the string.
44. Write a program that takes a list of integers as input and returns the number of numbers in
the list that are divisible by 2 but not by 3.
45. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are multiples of 5.
46. Write a program that takes a list of integers as input and returns the sum of all the numbers
in the list that are divisible by 5.
47. Write a program that takes a list of integers as input and returns the number of distinct
numbers in the list.
48. Write a program that takes a list of integers as input and returns a new list containing the
difference between each adjacent pair of numbers in the original list.
49. Write a program that takes a list of integers as input and returns the mode of the numbers in
the list.
50. Write a program that takes a list of integers as input and returns the number of times the
largest number appears in the list.
51. Write a program that takes a string as input and returns a new string with all the vowels
removed.
52. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are prime.
53. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are odd.
54. Write a program that takes a list of integers as input and returns the product of all the
numbers in the list.
55. Write a program that takes a list of integers as input and returns the number of numbers in
the list that are perfect cubes.
56. Write a program that takes a string as input and returns the reverse of the string.
57. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are even.
58. Write a program that takes a list of integers as input and returns the second largest number
in the list.
59. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are multiples of both 3 and 5.
60. Write a program that takes a list of integers as input and returns the number of numbers in
the list that are perfect squares.
61. Write a program that takes a string as input and returns the number of times the letter 'e'
appears in the string.
62. Write a program that takes a list of integers as input and returns the number of numbers in
the list that are greater than or equal to 100.
63. Write a program that takes a list of integers as input and returns a new list containing the
first 5 numbers in the original list.
64. Write a program that takes a list of integers as input and returns the number of times the
smallest number appears in the list.
65. Write a program that takes a string as input and returns a new string with all the spaces
removed.
66. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are between 20 and 50 (inclusive).
67. Write a program that takes a list of integers as input and returns the median of the numbers
in the list.
68. Write a program that takes a list of integers as input and returns a new list containing the
cumulative sum of the numbers in the original list.
69. Write a program that takes a list of integers as input and returns the number of numbers in
the list that are less than or equal to 10.
70. Write a program that takes a string as input and returns a new string with all the characters
in uppercase.
71. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are divisible by both 4 and 5.
72. Write a program that takes a list of integers as input and returns the number of numbers in
the list that are greater than the median.
73. Write a program that takes a list of integers as input and returns the sum of all the odd
numbers in the list.
74. Write a program that takes a string as input and returns the number of times the word "the"
appears in the string.
75. Write a program that takes a list of integers as input and returns a new list containing the
first 10 numbers in the original list.
76. Write a program that takes a list of integers as input and returns the sum of all the even
numbers in the list.
77. Write a program that takes a list of integers as input and returns the number of numbers in
the list that are between 50 and 100 (inclusive).
78. Write a program that takes a list of integers as input and returns a new list containing the
numbers in the original list in reverse order.
79. Write a program that takes a string as input and returns a new string with all the non-
alphabetic characters removed.
80. Write a program that takes a list of integers as input and returns the largest number in the
list that is not a multiple of 5.
81. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are perfect squares or perfect cubes.
82. Write a program that takes a string as input and returns a new string with the first letter of
each word capitalized.
83. Write a program that takes a list of integers as input and returns a new list containing the
numbers in the original list in sorted order.
84. Write a program that takes a string as input and returns a new string with all the characters
in lowercase.
85. Write a program that takes a list of integers as input and returns the average of the numbers
in the list.
86. Write a program that takes a list of integers as input and returns the number of times the
largest number in the list appears.
87. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are perfect squares and even.
88. Write a program that takes a string as input and returns a new string with all the vowels
capitalized.
89. Write a program that takes a list of integers as input and returns the number of times the
sum of two adjacent numbers in the list is even.
90. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are not prime.
91. Write a program that takes a string as input and returns a new string with the last letter of
each word removed.
92. Write a program that takes a list of integers as input and returns the second smallest number
in the list.
93. Write a program that takes a list of integers as input and returns a new list containing the
numbers in the original list that are greater than the average.
94. Write a program that takes a string as input and returns a new string with all the non-
alphanumeric characters removed.
95. Write a program that takes a list of integers as input and returns the number of times the
sum of two adjacent numbers in the list is odd.
96. Write a program that takes a list of integers as input and returns the smallest number in the
list that is not a multiple of 3.
97. Write a program that takes a string as input and returns a new string with the characters in
reverse order.
98. Write a program that takes a list of integers as input and returns a new list containing the
numbers in the original list that are less than the average.
99. Write a program that takes a list of integers as input and returns a new list containing only
the numbers that are perfect cubes or perfect squares, and that are greater than or equal to
10.
100. Write a program that takes a list of integers as input and returns the largest number
in the list that is not divisible by any other number in the list.