Pagini recente » Cod sursa (job #186175) | Cod sursa (job #2867814) | Cod sursa (job #17742) | Cod sursa (job #2922237) | Cod sursa (job #1190000)
#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");
}