Basic Function Practice:
- Simple Addition Function: Write a function that takes two integers as input and returns their sum. Call this function from
main(). - Function to Find the Maximum of Two Numbers: Write a function
max()that accepts two integer arguments and returns the larger of the two. - Temperature Conversion: Write a function that converts a given temperature from Celsius to Fahrenheit.
- Function to Check Even or Odd: Write a function
isEven()that takes an integer and returns1if it’s even and0if it’s odd. - Factorial Calculation: Write a recursive function
factorial()to calculate the factorial of a number. - Simple Interest Calculation: Write a function to calculate the simple interest, given principal, rate of interest, and time (in years).
Intermediate Function Practice:
- Prime Number Check: Write a function
isPrime()that takes an integer as input and returns1if it’s a prime number and0otherwise. - Function to Reverse a Number: Write a function
reverseNumber()that takes an integer as input and returns the reverse of that number. - String Length Calculation: Write a function
stringLength()that takes a string as input and returns the length of the string without using thestrlen()function. - Find GCD of Two Numbers: Write a function
gcd()that returns the greatest common divisor (GCD) of two integers using recursion. - Fibonacci Series: Write a function
fibonacci(n)that prints the firstnterms of the Fibonacci sequence using recursion.
Advanced Function Practice:
- Check Palindrome: Write a function
isPalindrome()that checks if a given string is a palindrome. - Pass By Reference: Write a function to swap two numbers using pass-by-reference (using pointers).
- Matrix Addition: Write a function
addMatrices()that takes two 2D arrays (matrices) and returns the result of their addition. - String Comparison: Write a function
compareStrings()that takes two strings and returns0if they are equal, and a non-zero value if they are not (without usingstrcmp()). - Function to Find Minimum and Maximum in an Array: Write two functions
findMin()andfindMax()that take an array and its size as input, and return the minimum and maximum values, respectively.
Function and Arrays Practice:
- Sum of Array Elements: Write a function
sumArray()that takes an array and its size as input and returns the sum of all its elements. - Average of Array Elements: Write a function
averageArray()that calculates and returns the average of the elements in an array. - Search Element in Array: Write a function
searchElement()that searches for a specific element in an array and returns its index or-1if the element is not found. - Sorting an Array: Write a function
sortArray()that sorts an array of integers in ascending order using any sorting algorithm (e.g., bubble sort).
Function with Structures:
- Structure and Function: Define a structure
Studentwithname,age, andmarks. Write a functiondisplayStudentDetails()that takes aStudentstructure as input and prints the student’s details. - Pass Structure to Function: Write a program where you create a structure
Pointwithxandycoordinates, and write a functiondistance()to calculate the distance between two points.
Advanced Recursive Function Practice:
- Tower of Hanoi: Write a recursive function to solve the Tower of Hanoi puzzle.
- Power of a Number: Write a recursive function
power(base, exponent)to calculate the value of a number raised to a power. - Binary Search: Write a recursive function
binarySearch()to search for an element in a sorted array.
