Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
21 views5 pages

TP10 Function

Uploaded by

davinsorn.dv
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)
21 views5 pages

TP10 Function

Uploaded by

davinsorn.dv
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
You are on page 1/ 5

Name: Sorn Davin

ID : e20221238

TP-10-Function
Problem1: Create a function in C programming to display all sequence numbers from 1 to n except the
number 10, where n is a parameter of this function.
Code:

Result:

Problem2: Create a function in C programming to compute a cube of a number n, where n is taken as a


parameter of this function. This function has a return value which is the cube of the number n passed
though the function parameter. The program asks a user to input the number n, then call the function to
compute the cube. Keep the program running as an infinite loop such that the user can test with as many
numbers as possible.

Code:
Result:

Problem3: Design a program to be able to find the diameter, circumference and surface of a circle using
a function. The function takes one parameter, i.e., the radius. The function should return three data such
as the diameter, the circumference, and the area of this circle.
Code:
Result:

Problem4: Write a C program to ask a user for 10 numbers. Create a function to find the minimum and
maximum. Finally display those values to the user on screen. The signature of this function is: MinMax
findMinMax(int numbers[ ]){ ………. }
Code:

Result:
Problem5: Create a C program to solve the quadratic equation ax^2+bx+c=0 using a function. The
function takes 3 parameters which are the coefficients of the equation such as a, b and c. This function
returns some structure data such as status code (1: the equation has double root, 2: the equation has 2
roots, 3: the equation has complex roots), root x1, and root x2. struct Root{ int status_code; float x1; float
x2; } The signature of this function is defined by: Root solveQuadratic(int a, int b, int c)
Code:

Result:

You might also like