Question 01
Write a C program that defines a function called max_of_three which takes three integers as parameters and returns the largest of the three integers. The program should prompt the user to enter three integers, call the max_of_three function, and display the result.
Question 02
Write a C program that defines a function called gcd which calculates the Greatest Common Divisor (GCD) of two integers using the Euclidean algorithm. The program should prompt the user to enter two integers, call the gcd function, and display the result.
Question 03
Write a C program that defines a function called sum_of_digits which calculates the sum of the digits of a given positive integer. The program should prompt the user to enter a number, call the sum_of_digits function, and display the sum of its digits.
Question 04
Write a C program that defines two functions:
-
A function
is_evenwhich takes an integer and returns1if the number is even and0if the number is odd. -
A function
print_even_or_oddthat callsis_evenand printsEvenif the number is even orOddif the number is odd.
The program should prompt the user to enter an integer, call print_even_or_odd, and display whether the number is even or odd.
Question 05
Write a C program that defines three functions:
-
A function
is_positivewhich checks if an integer is positive (returns1if positive,0otherwise). -
A function
is_negativewhich checks if an integer is negative (returns1if negative,0otherwise). -
A function
check_numberthat calls bothis_positiveandis_negativeto determine if the number is positive, negative, or zero, and prints the appropriate message.
The program should prompt the user to enter an integer, call the check_number function, and display whether the number is positive, negative, or zero.