Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- main(){
- float cotiz=0, cant=0, pesos=0, acumulado=0;
- FILE * histtxt = fopen("historial.txt", "a");
- FILE * dolartxt = fopen("dolar.txt", "r");
- FILE * acumtxt = fopen("acumulado.txt", "r+");
- fscanf(dolartxt, "%f", &cotiz);
- fscanf(acumtxt, "%f", &acumulado);
- printf("Cotizacion actual del dolar: %.2f\n", cotiz);
- printf("Para SALIR Ingrese cantidad: 0\n\n");
- do{
- printf("Ingrese cantidad: ");
- scanf("%f", &cant);
- if(cant!=0){
- acumulado+=cant;
- pesos=cotiz*cant;
- printf("Cantidad en pesos: %.2f\n\n", pesos);
- rewind(acumtxt);
- fprintf(acumtxt, "%.2f", acumulado);
- fprintf(histtxt, "Cantidad: %.2f Cotizacion: %.2f Pesos: %.2f\n", cant, cotiz, pesos);
- }
- }while(cant != 0);
- fclose(histtxt);
- fclose(dolartxt);
- fclose(acumtxt);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement