Advertisement
clari-g

junio-parcial1

Jul 15th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4.  
  5. main(){
  6.     float cotiz=0, cant=0, pesos=0, acumulado=0;
  7.  
  8.     FILE * histtxt = fopen("historial.txt", "a");
  9.     FILE * dolartxt = fopen("dolar.txt", "r");
  10.     FILE * acumtxt = fopen("acumulado.txt", "r+");
  11.  
  12.     fscanf(dolartxt, "%f", &cotiz);
  13.     fscanf(acumtxt, "%f", &acumulado);
  14.  
  15.     printf("Cotizacion actual del dolar: %.2f\n", cotiz);
  16.     printf("Para SALIR Ingrese cantidad: 0\n\n");
  17.     do{
  18.         printf("Ingrese cantidad: ");
  19.         scanf("%f", &cant);
  20.  
  21.         if(cant!=0){
  22.             acumulado+=cant;
  23.  
  24.             pesos=cotiz*cant;
  25.             printf("Cantidad en pesos: %.2f\n\n", pesos);
  26.  
  27.             rewind(acumtxt);
  28.             fprintf(acumtxt, "%.2f", acumulado);
  29.             fprintf(histtxt, "Cantidad: %.2f Cotizacion: %.2f Pesos: %.2f\n", cant, cotiz, pesos);
  30.         }
  31.     }while(cant != 0);
  32.  
  33.     fclose(histtxt);
  34.     fclose(dolartxt);
  35.     fclose(acumtxt);
  36.     getch();
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement