C语言

来源:互联网 发布:淘宝灯具3c认证怎么弄 编辑:程序博客网 时间:2024/06/03 04:16
////  main.c//  myc////  Created by clz on 16/5/4.//  Copyright © 2016年 clz. All rights reserved.//#include <stdio.h>#include <string.h>#include "Hou.h"float total = 0.0;short count = 0;short tax_percent = 6;float add_with_tax(float f){    float tax_rate = 1+tax_percent/100.0;        total = total+(f*tax_rate);        count = count+1;    return total;}int main(int argc, const char * argv[]) {    float val;        printf("price of item:");        while (scanf("%f",&val)==1) {        printf("Total so far:%.2f\n",add_with_tax(val));        printf("Price of item:");    }        printf("\nFinal total:%.2f\n",total);    printf("Number of items:%hi\n",count);        return 0;}

0 0
原创粉丝点击