This site is no longer active, all members have migrated to devotedcheating.com . Thankyou



 
Actionhacks.netHomeFAQRegisterLog in

Share | 
 

 Simple Code that adds, multiplies, averages, and subtracts two numbers, then saves it to txt

Go down 
AuthorMessage
Tate
Admin
Admin
avatar

Posts : 208
Reputation : 17
Join date : 2009-09-19
Age : 22

PostSubject: Simple Code that adds, multiplies, averages, and subtracts two numbers, then saves it to txt   Fri Nov 27, 2009 2:19 pm

This code makes the color green, the title "Calc that saves as text file", and it saves basic addition, averaging, multiplication, and subtraction as a text file.

Code:
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    system("TITLE Calc That Saves as Text File");
    system("COLOR 2");
   
   
    int num1;
    int num2;
   
cout << "Enter your first number: " << endl;
cin >> num1;
cout << "Good. Your first number is " << num1 << "." << endl;
cout << "Enter your second number: " << endl;
cin >> num2;
cout << "Good your second number is " << num2 << "." << endl;
   
fstream file;
file.open("numbers.txt",ios::out);
file << "Added: " << num1 + num2 << endl;   
file << "Averaged: " << (num1 + num2) / 2 << endl;
file << "Subtracted: " << num1 - num2 << endl;
file << "Multiplied: " << num1 * num2 << endl;
system("PAUSE");
return 0;
}

}



Really simple, just use this for learning.

_________________
"Never pick a fight with an idiot. They'll simply bring you down to their level, then win by experience."
___________________________________
Back to top Go down
 
Simple Code that adds, multiplies, averages, and subtracts two numbers, then saves it to txt
Back to top 
Page 1 of 1
 Similar topics
-
» Emoticon Code from Neopets!
» JOIN THE MOST BEASTLY DOJO WITH THE CODE: AFAEAHGE
» New Cheerleading Move Code
» Animal ID code not working?
» Simple-c-chess-engine

Permissions in this forum:You cannot reply to topics in this forum
 :: Public Section: Coding :: C++ :: Source Codes-
Jump to: