Home / Programs / Write a program to returning more than one value from a function.
🚀 Programming Example

Write a program to returning more than one value from a function.

👁 938 Views
💻 Practical Program
📘 Step Learning
Write a program to returning more than one value from a function.

💻 Program Code

#include"stdio.h"
int main()
{
	float r, area, perimeter;
	float compute(float,float*);
	printf("\n enter the radius of the circle:");
	scanf("%f",&r);
	area=compute(r, &perimeter);
	printf("\n AREA = %f", area);
	printf("\n PERIMETER = %f", perimeter);
	return 0;
}
float compute(float r, float *p)
{
	float a;
	a=(float)3.1415 * r * r;
	*p=(float)3.1415 * 2 * r;
	return a;
}


                        

🖥 Program Output

 enter the radius of the circle:5

 AREA = 78.537506
 PERIMETER = 31.415001
 
                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.