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 returns 1 if it’s even and 0 if 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 returns 1 if it’s a prime number and 0 otherwise.
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 the strlen() 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 first n terms 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 returns 0 if they are equal, and a non-zero value if they are not (without using strcmp()).
Function to Find Minimum and Maximum in an Array: Write two functions findMin() and findMax() 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 -1 if 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 Student with name, age, and marks. Write a function displayStudentDetails() that takes a Student structure as input and prints the student’s details.
Pass Structure to Function: Write a program where you create a structure Point with x and y coordinates, and write a function distance() 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.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok