Tambien lo pueden descargar de aqui y abrirlo directamente tanto el codigo como el programa: https://mega.co.nz/#F!4M9hUKBJ!jA_TDwhQ0pCxJN3tzg6Zrg
Código
#include <iostream> #include <string.h> #include <windows.h> #include <conio.h> #include <fstream> using namespace std; /*Diseñado por Addison Jimenez*/ void sumar(); void restar(); void multiplicar(); void dividir(); FILE *pf; int op; float num_1; float resultado_sumar; float resultado_restar; float resultado_multiplicar; float resultado_dividir; int main() { system("color 0a"); ofstream verificando; verificando.open("info.txt"); { ofstream verificando("info.txt"); verificando << "================================================================ \n"; verificando << " BIENVENIDO USUARIO A LA CALCULADORA (4 FUNCIONES) \n"; verificando << "================================================================ \n"; verificando.close(); } do{ { ifstream verificando("info.txt"); if(verificando.fail()) cout << "ERROR AL ABRIR EL ARCHIVO SOLICITADO \n"; verificando.close(); } cout << "============================================================================== \n"; cout << " BIENVENIDO USUARIO A LA CALCULADORA (4 FUNCIONES) \n"; cout << "============================================================================== \n\n"; cout << "\tELIGE LA OPERACION A REALIZAR DE LOS DOS NUMEROS ANTERIORES \n\n"; cout << "\n\t\t\t1.* SUMA"; cout << "\n\t\t\t2.* RESTA"; cout << "\n\t\t\t3.* MULTIPLICACION"; cout << "\n\t\t\t4.* DIVISION"; cout << "\n\t\t\t5.* SALIR DEL APLICATIVO"; cout << "\n\n\t\t\tELIGE TU OPCION: "; cin >> op; system("cls"); switch(op){ case 1: sumar(); break; case 2: restar(); break; case 3: multiplicar(); break; case 4: dividir(); break; case 5: system("color 0d"); cout << "============================================================================== \n"; cout << "\n\n\t\t FINALIZO EL PRORGAMA! VUELVA PRONTO\n\n\n"; cout << "============================================================================== \n\n"; break; default: system("color 0c"); cout << "============================================================= \n"; cout << "\tERROR - INTRODUZCA OTRA OPCION O NUMERO\n"; cout << "============================================================= \n\n"; cin >> op; getch(); system("cls"); fflush(stdin); break; } }while(op!=5); getch(); return EXIT_SUCCESS; } void sumar(){ fflush(stdin); // Para limpiar el bufer y no haya problemas con la entrada de caracteres. { ifstream verificando("info.txt"); if(verificando.fail()) cout << "ERROR AL ABRIR EL ARCHIVO SOLICITADO \n"; verificando.close(); } system("color 0b"); cout << "============================================================================== \n"; cout << " BIENVENIDO USUARIO A LA CALCULADORA (4 FUNCIONES) \n"; cout << "============================================================================== \n\n"; cout << "DIGITE EL PRIMER NUMERO\n"; cin >> resultado_sumar; cout << "\n"; string seguir; do { cout << "DIGITE EL SEGUNDO NUMERO\n"; cin >> num_1; cout << "\n"; resultado_sumar = num_1 + resultado_sumar; system("color 0b"); cout << "EL RESULTADO ES: " << resultado_sumar << "\n\n"; cout << "DESEA CONTINUAR SUMANDO DIGITE (si/no)\n"; cin >> seguir; cout << "\n\n"; } while (seguir!="no"); { ofstream extrayendo; extrayendo.open("resultados_sumar.txt", ios::out|ios::app); extrayendo << "================================================================ \n"; extrayendo << "PRIMER NUMERO " << resultado_sumar << " == SEGUNDO NUMERO " << num_1 << " == RESULTADO" << resultado_sumar << "\n"; extrayendo << "================================================================ \n"; extrayendo.close(); } system("color 0e"); cout << "LOS DATOS INGRESADOS FUERON EXPORTADOS EN ARCHIVO TEXTO\n"; system("pause"); system("cls"); system("color 0a"); fflush(stdin); // Para limpiar el bufer y no haya problemas con la entrada de caracteres. } void restar(){ fflush(stdin); // Para limpiar el bufer y no haya problemas con la entrada de caracteres. { ifstream verificando("info.txt"); if(verificando.fail()) cout << "ERROR AL ABRIR EL ARCHIVO SOLICITADO \n"; verificando.close(); } system("color 0b"); cout << "============================================================================== \n"; cout << " BIENVENIDO USUARIO A LA CALCULADORA (4 FUNCIONES) \n"; cout << "============================================================================== \n\n"; cout << "DIGITE EL PRIMER NUMERO\n"; cin >> resultado_restar; cout << "\n"; string seguir; do { cout << "DIGITE EL SEGUNDO NUMERO\n"; cin >> num_1; cout << "\n"; resultado_restar = num_1 - resultado_restar; cout << "EL RESULTADO ES: " << resultado_restar << "\n\n"; cout << "DESEA CONTINUAR RESTANDO DIGITE (si/no)\n"; cin >> seguir; cout << "\n\n"; } while (seguir!="no"); { ofstream extrayendo; extrayendo.open("resultados_restar.txt", ios::out|ios::app); extrayendo << "================================================================ \n"; extrayendo << "PRIMER NUMERO " << resultado_restar << " == SEGUNDO NUMERO " << num_1 << " == RESULTADO" << resultado_restar << "\n"; extrayendo << "================================================================ \n"; extrayendo.close(); } system("color 0e"); cout << "LOS DATOS INGRESADOS FUERON EXPORTADOS EN ARCHIVO TEXTO\n"; system("pause"); system("cls"); system("color 0a"); fflush(stdin); // Para limpiar el bufer y no haya problemas con la entrada de caracteres. } void multiplicar(){ fflush(stdin); // Para limpiar el bufer y no haya problemas con la entrada de caracteres. { ifstream verificando("info.txt"); if(verificando.fail()) cout << "ERROR AL ABRIR EL ARCHIVO SOLICITADO \n"; verificando.close(); } system("color 0b"); cout << "============================================================================== \n"; cout << " BIENVENIDO USUARIO A LA CALCULADORA (4 FUNCIONES) \n"; cout << "============================================================================== \n\n"; cout << "DIGITE EL PRIMER NUMERO\n"; cin >> resultado_multiplicar; cout << "\n"; string seguir; do { cout << "DIGITE EL SEGUNDO NUMERO\n"; cin >> num_1; cout << "\n"; resultado_multiplicar = num_1 * resultado_multiplicar; cout << "EL RESULTADO ES: " << resultado_multiplicar << "\n\n"; cout << "DESEA CONTINUAR MULTIPLICANDO DIGITE (si/no)\n"; cin >> seguir; cout << "\n\n"; } while (seguir!="no"); { ofstream extrayendo; extrayendo.open("resultados_multiplicar.txt", ios::out|ios::app); extrayendo << "================================================================ \n"; extrayendo << "PRIMER NUMERO " << resultado_multiplicar << " == SEGUNDO NUMERO " << num_1 << " == RESULTADO" << resultado_multiplicar << "\n"; extrayendo << "================================================================ \n"; extrayendo.close(); } system("color 0e"); cout << "LOS DATOS INGRESADOS FUERON EXPORTADOS EN ARCHIVO TEXTO\n"; system("pause"); system("cls"); system("color 0a"); fflush(stdin); // Para limpiar el bufer y no haya problemas con la entrada de caracteres. } void dividir(){ fflush(stdin); // Para limpiar el bufer y no haya problemas con la entrada de caracteres. ifstream verificando("info.txt"); if(verificando.fail()) cout << "ERROR AL ABRIR EL ARCHIVO SOLICITADO \n"; verificando.close(); system("color 0b"); cout << "============================================================================== \n"; cout << " BIENVENIDO USUARIO A LA CALCULADORA (4 FUNCIONES) \n"; cout << "============================================================================== \n\n"; cout << "DIGITE EL PRIMER NUMERO\n"; cin >> resultado_dividir; cout << "\n"; cout << "DIGITE EL SEGUNDO NUMERO\n"; cin >> num_1; cout << "\n"; resultado_dividir = num_1 / resultado_dividir; cout << "EL RESULTADO ES: " << resultado_dividir << "\n\n"; if (resultado_dividir==0) { system("color 0c"); cout << "NUNCA SE PUEDE DIVIDIR POR CERO \n\n"; } else { resultado_dividir = resultado_dividir/num_1; } { ofstream extrayendo; extrayendo.open("resultados_dividir.txt", ios::out|ios::app); extrayendo << "================================================================ \n"; extrayendo << "PRIMER NUMERO " << resultado_dividir << " == SEGUNDO NUMERO " << num_1 << " == RESULTADO" << resultado_dividir << "\n"; extrayendo << "================================================================ \n"; extrayendo.close(); } system("color 0e"); cout << "LOS DATOS INGRESADOS FUERON EXPORTADOS EN ARCHIVO TEXTO\n"; system("pause"); system("cls"); system("color 0a"); fflush(stdin); // Para limpiar el bufer y no haya problemas con la entrada de caracteres. }