0% found this document useful (0 votes)
4 views2 pages

C Programming Practice Problems

The document contains a list of practice problems for C programming, covering various topics such as Armstrong numbers, Prime numbers, Pascal's triangle, array manipulation, string operations, matrix operations, and date validation. Each problem requires the implementation of specific functions and testing them in the main function. The problems are designed to enhance programming skills through practical coding exercises.

Uploaded by

akkineel292
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

C Programming Practice Problems

The document contains a list of practice problems for C programming, covering various topics such as Armstrong numbers, Prime numbers, Pascal's triangle, array manipulation, string operations, matrix operations, and date validation. Each problem requires the implementation of specific functions and testing them in the main function. The problems are designed to enhance programming skills through practical coding exercises.

Uploaded by

akkineel292
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PRACTICE PROBLEMS

1) Write a C function that takes two integers as the lower and upper bound and prints all the Armstrong
numbers within that range. Test the function by calling it from main().
2) Write a C function that takes two integers as the lower and upper bound and prints all the Prime
numbers within that range. Test the function by calling it from main().
3) Write a C program to display Pascal’s triangle till the n-th row. For example, following is the Pascal’s
triangle till 7th row.

4) Write a C program to compute reverse of an array (NOT JUST printing in reverse order!) without using
auxiliary array.
5) Write a C program to find frequency of each element in an array.
6) Define a C function to compute the transpose of an input matrix. Now write the main() function to
read a matrix of size 𝒎 × 𝒏 and then call the previously defined function to compute its transpose.
7) Write a C program to check whether a text (string) is a palindrome or not.
8) Write a C program to count number of vowels, consonant, and digits in a string taken as input from
the keyboard.
9) Write a C program to convert a string from lowercase to uppercase and vice versa.
10) Write a C program to compute multiplication of two matrices. The dimensions and the elements of
the matrices must be read through the keyboard. In case the dimensions are not appropriate, relevant
message should be printed.

11) Develop your own functions to append a string to the end of another string (do not use library
functions). Test the function while calling it from main().

12) Write a C function that computes the product of two matrices of size m by n and n by m. The main
function supplies the value of m, n, and the two matrices.

13) You are given two numbers, 𝒏 and 𝒑. You need to find the sum of the 𝒑-th powers of all numbers
from 1 to 𝒏. That is, you need to find out: 𝟏𝒑 + 𝟐𝒑 + 𝟑𝒑 + 𝟒𝒑 · · · + 𝒏𝒑
For example if 𝒏=4, 𝒑=2 Ans. = 𝟏𝟐 + 𝟐𝟐 + 𝟑𝟐 + 𝟒𝟐 = 𝟑𝟎
Solve the problem by defining two functions (other than main() function) performing the following tasks:
• Calculating the power of any number recursively.
• Calculating the sum of series recursively.
14) You are given two numbers, 𝒏 and 𝒑. You need to find the sum of the 𝒑-th powers of all numbers
from 1 to 𝒏. That is, you need to find out: 𝟏𝒑 − 𝟐𝒑 + 𝟑𝒑 − 𝟒𝒑 · · · + 𝒏𝒑
For example if 𝒏=4, 𝒑=2 Ans. = 𝟏𝟐 − 𝟐𝟐 + 𝟑𝟐 − 𝟒𝟐 = −𝟏𝟎
Solve the problem by defining two functions (other than main() function) performing the following tasks:
• Calculating the power of any number recursively.
• Calculating the sum of series recursively.

15) Define a structure data type called time_struct containing three members: integer hour, integer
minute, and integer second.
Develop program that would assign values to the individual members and display the time in the
following form: 23:42:51

16) Write a C function that converts a binary number to its decimal equivalent. Test the function while
calling it from main().
[DO NOT USE LIBRARY FUNCTION]

17) Write a C function that converts a decimal number to its binary equivalent. Test the function while
calling it from main().[DO NOT USE LIBRARY FUNCTION]

18) Use pointer to input an array of n number of integers. Now, using the pointer, traverse through the
array to indicate the even numbers and the odd numbers.

19) Use pointer to read a string from the terminal and then print whether it is Palindrome or not using a
RECURSIVE function

20) Write a function (using pointer parameters) that compares two integer arrays to see whether they
are identical. The function returns 1 if they are identical, and 0 otherwise.

21) Write a function (using pointer parameters) that receives a sorted array of integers and an integer
value, and inserts the value in its correct position.

22) Using pointers, write a function that receives a character string and a character as arguments and
deletes all the occurrences of this character in the string. The function should return the corrected string
with no holes.

23) Define a structure data type named date containing three integer members: day, month, and year.
Develop a program to
perform the following tasks:
a. To read data into structure members by a function.
b. To validate the date entered by another function.
c. To print the date in the format: April 20, 2023
[The input should be three integers, like: 20 4 2023
Example of invalid date: 31 4 2023 - Invalid date…. because April has only 30 days
29 2 2023 - Invalid date…because 2023 is not a leap year]

You might also like