C语言,输入三个数求其平均值!

#include <stdio.h>
float average(int n1, int n2, int n3);
float average(int n1, int n2, int n3) {
	float a;
	a = (float)(n1 + n2 + n3) / 3;
	return a;
}

void main() {
	int n1, n2, n3;
	float a;
	printf("请输入第一个整数;");
	scanf("%d", &n1);
	getchar();
	printf("请输入第二个整数;");
	scanf("%d", &n2);
	getchar();
	printf("请输入第三个整数;");
	scanf("%d", &n3);
	getchar();
	a = average(n1, n2, n3);
	printf("你所要的平均值是;%.2f", a);
}

 

    原文作者:吃人陈乐游刘
    原文地址: https://blog.csdn.net/qq_53463161/article/details/116051893
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞