Question 01

Write a C program that generates a multiplication table up to 10x10 using nested for loops. Each cell in the table should display the product of the row and column numbers.

Question 02

Write a C program that prints a right-aligned triangle of asterisks (*). The triangle should have 5 rows, with the first row containing 1 asterisk, the second row containing 2 asterisks, and so on, up to the fifth row, which should contain 5 asterisks.

For example, if the number of rows is 5, the output should be:

    *
   **
  ***
 ****
*****

If the number of rows is 6, the output should be:

     *
    **
   ***
  ****
 *****
******

Question 03

Write a C program that displays a pyramid of numbers. The pyramid should have 5 rows, with each row displaying the row number repeated. The first row should contain 1, the second row should contain 2 twice, and so on, up to the fifth row, which contains the number 5 five times.

The output should be:

    1 
   2 2 
  3 3 3 
 4 4 4 4 
5 5 5 5 5

Question 04

Write a C program that generates a checkerboard pattern of ‘*‘ and ‘#‘ characters. The pattern should be 8x8, with alternating symbols in each row, so that it resembles a checkerboard. The output should be:

* # * # * # * # 
# * # * # * # * 
* # * # * # * # 
# * # * # * # * 
* # * # * # * # 
# * # * # * # * 
* # * # * # * # 
# * # * # * # * 

Question 05

Write a C program that finds and prints all pairs of numbers in an array whose sum is equal to a given target value.

For example, if the array is {1, 2, 3, 4, 5, 6, 7}, and the target value is 7, the output should be:

Pairs with sum 7:
(1, 6)
(2, 5)
(3, 4)
Last modified: Saturday, 23 November 2024, 4:28 PM