使用函数求奇数和

#include<stdio.h>
int even(int n)
{
	int z;
	if(n%2==0)
	z=1;
	else 
	z=0;
}
int main()
{
	int n,s=0,c;
	scanf("%d",&n);
	while(n>0)
	{
		c=even(n);
		if(c)
		{
			s+=n;
		}
		scanf("%d",&n);
	}
	printf("The sum of the odd numbers is %d",s);
}

猜你喜欢

转载自blog.csdn.net/qq_41404557/article/details/79870295