《C语言入门经典》Ivor Horton第10章习题2

//习题10.2 编写一个程序,读入以下数值,并输出它们的和:
//$3.50,$4.75,$9.95,$2.50
#include<stdio.h>
#define count 4
int main(void)
{

	double amount[count];
	double total;
	printf("enter the four data\n");
	for(int i=0;i<count;i++)
	{
		scanf("%*[ $,]%lf",&amount[i]);
		total+=amount[i];
	}
	printf("\nthe total is %lf",total);
	return 0;
}

你可能感兴趣的:(编程,函数,C语言,存储)