Cod sursa(job #1190000)

Utilizator PulseHexFlorea Andrei PulseHex Data 24 mai 2014 10:42:19
Problema A+B Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.12 kb
#include <iostream>
#include <fstream>
#include <stdlib.h>

using namespace std;
void aplusb();

int main()
{
    bool apprun=true;
    char decision;
    while(apprun==true)
    {
        cout << "a.A+B\n";
        cout << "q.Quit\n";
        cout << "What would you like to do ? \n";
        cin >> decision;
        switch(decision)
        {
        case 'a':
            {
                aplusb();
                break;
            }
        case 'q':
            {
                apprun=false;
                break;
            }
        default:
            {
                cout << "\nInvalid command !\n";
                system("pause");
            }
        }
        system("cls");
    }
    return 0;
}
void aplusb()
{
    int a , b , c;

    cout << "\n\nInsert the first number : ";
    cin >> a;
    cout << "\nInsert the second number : ";
    cin >> b;

    ofstream write("aplusb.txt");
    write << a+b;
    write.close();
    ifstream read("aplusb.txt");
    read >> c ;
    read.close();
    cout << "Sum of a and b : " << c << endl ;
    system("pause");
}