| Welcome | |
|---|---|
|
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials! You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>! |
|
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
double firstnum;
double secondnum;
char opperator;
char f;
int alkuun();
cout << "Please type your first number: ";
cin >> firstnum;
cout << "Ok good now enter operator (+,-,*,/): ";
cin >> opperator;
cout << "Operator given, now give second number: ";
cin >> secondnum;
cout << "Numbers and operator given and \nAnswer is: ";
if ( opperator == '+' )
{
cout << firstnum << " + " << secondnum << " = " << firstnum + secondnum << endl;
}
else if ( opperator == '-' )
{
cout << firstnum << " - " << secondnum << " = " << firstnum - secondnum << endl;
}
else if ( opperator == '*' )
{
cout << firstnum << " * " << secondnum << " = " << firstnum * secondnum << endl;
}
else if ( opperator == '/' )
{
cout << firstnum << " / " << secondnum << " = " << firstnum / secondnum << endl;
}
alkuun();
}
int alkuun()
{
string answer;
cout << "If you want to start again type yes or if you want to quit write no.\nEnter your answer: ";
cin >> answer;
if ( answer == "yes" )
{
main();
}
else if ( answer == "no" )
{
goto Loppu;
}
else if ( answer != "no" && answer != "yes" )
{
cout << "Enter proper answer!" << endl;
alkuun();
}
Loppu:
return 0;
}
#include "stdafx.h"
#include <iostream>
using namespace std;
int main ()
{
double number;
double number2;
char choice;
cout << "\n";
cout << "Welcome to Calculator\n";
cout << "\n";
cout << "Enter your first number:";
cin >> number;
cout << "\n";
cout << "Enter your operation sign (+,-,/,*):";
cin >> choice;
cout << "\n";
cout << "Enter your second number:";
cin >> number2;
cout << "\n";
cout << number << choice<<number2<<"=\n";
cout << "\n";
if (choice == '+') cout <<(number+number2);
else if (choice == '-') cout << (number - number2);
else if (choice == '*') cout << (number * number2);
else if (choice == '/') cout << (number / number2);
cout << "\n";
cout << "\n";
cout << "Thanks for using my calculator!\n";
cout <<"Want to use it again?(y/n)";
char again;
int x=1;
cin >> again;
for (;again=='y'&& x==1;main()){x++;}
for (;again !='y';){break;}
char g;
cin >> g;
return 0;
}
#include "stdafx.h"
#include <iostream>
using namespace std ;
int main ()
{
int number;
int number2;
char choice;
cout << "Choose a number \n";
cin >> number;
cout << "awesome, now pick an operation. Add + subtract - multiply * or devide / \n" ;
cin >> choice;
cout << " Great now choose another number \n";
cin >> number2;
if ( choice == '+')
{
cout << "your answer is : ";
cout << number + number2;
}
if ( choice == '-')
{
cout << "your answer is : ";
cout << number - number2;
}
if ( choice == '/')
{
cout << "your answer is : ";
cout << number / number2;
}
if ( choice == '*')
{
cout << "your answer is : ";
cout << number * number2;
}
char f;
cin >> f ;
return 0 ;
}
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
float one;
float two;
char math;
cout << "Type in your first number: ";
cin >> one;
cout << "Do you want to Add +, Subtract -, Multiply * or Divide /\n";
cout << "Type your choice here: ";
cin >> math;
cout << "Type in your second number:";
cin >> two;
if(math == '+')
{
cout << "Your answer is: " << one << math << two << "=" << one + two << endl;
}
if(math == '-')
{
cout << "Your answer is: " << one << math << two << "=" << one - two << endl;
}
if(math == '*')
{
cout << "Your answer is: " << one << math << two << "=" << one * two << endl;
}
if(math == '/')
{
cout << "Your answer is: " << one << math << two << "=" << one / two << endl;
}
char o;
cin >> o;
return 0;
}#include <iostream>
using namespace std;
int main()
{
int choice;
float num1;
float num2;
do {
cout <<"(1) - Addition" << endl;
cout <<"(2) - Subtraction" << endl;
cout <<"(3) - Multiplication" << endl;
cout <<"(4) - Division" << endl;
cout <<"(5) - Quit" << endl;
cout << endl;
cin >> choice;
}
while (choice <= 0 || choice >= 6 );
cout << endl;
cout <<"Number : ";
cin >> num1;
cout << endl;
cout <<"Number : ";
cin >> num2;
cout << endl;
switch (choice) {
case 1:
cout << num1 << " + " << num2 << " = " << num1+num2 << endl;
break;
case 2:
cout << num1 << " - " << num2 << " = " << num1-num2 << endl;
break;
case 3:
cout << num1 << " x " << num2 << " = " << num1*num2 << endl;
break;
case 4:
cout << num1 << " : " << num2 << " = " << num1/num2 << endl;
break;
case 5:
return 0;
break;
}
system("PAUSE");
return 0;
}
// Example.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
float one;
float two;
char math;
cout << "Type in your first number: ";
cin >> one;
cout << "Do you want to Add +, Subtract -, Multiply * or Divide /\n";
cout << "Type your choice here: ";
cin >> math;
cout << "Type in your second number:";
cin >> two;
switch(math)
{
case '+':
cout << "Your answer is: " << one << math << two << "=" << one + two << endl;
break;
case '-':
cout << "Your answer is: " << one << math << two << "=" << one - two << endl;
break;
case '*':
cout << "Your answer is: " << one << math << two << "=" << one * two << endl;
break;
case '/':
cout << "Your answer is: " << one << math << two << "=" << one / two << endl;
break;
}
char yesno;
cout << "Do you want to start again? Y/N \n";
cout << "Type your choice: ";
cin >> yesno;
if (yesno == 'Y')
{
main();
}
return 0;
}#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
float userFirstNumber = 0;
float userSecondNumber = 0;
char mathOperator = ' ';
char exit;
cout << "Simple Calculator" << endl << endl;
cout << "Please enter first number: ";
cin >> userFirstNumber;
cout << endl << "Select a mathematical operator (+, - , * , /): ";
cin >> mathOperator;
cout << endl << "Please enter second number: ";
cin >> userSecondNumber;
if (mathOperator == '+')
cout << endl << endl << userFirstNumber << " " << mathOperator << " " << userSecondNumber << " = " << userFirstNumber + userSecondNumber;
else if (mathOperator == '-')
cout << endl << endl << userFirstNumber << " " << mathOperator << " " << userSecondNumber << " = " << userFirstNumber - userSecondNumber;
else if (mathOperator == '*')
cout << endl << endl << userFirstNumber << " " << mathOperator << " " << userSecondNumber << " = " << userFirstNumber * userSecondNumber;
else if (userSecondNumber == 0)
{
cout << "Divide by zero is illegal";
cout << endl << "Please try again!" << endl << endl;
main();
}
else
cout << endl << endl << userFirstNumber << " " << mathOperator << " " << userSecondNumber << " = " << userFirstNumber / userSecondNumber;
cout << endl;
cin >> exit;
if (exit == 'x')
return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
char z;
double a,b;
cout <<"\n";
cout <<" CALCULATOR +-*/" <<"\n";
cout <<"================================================================================" <<"\n";
cout <<"\n";
cout <<"\n";
do{
cout <<"Input number A : ";
cin >> a ;
cout <<"Input number B : ";
cin >> b ;
cout <<" Chose operation: ";
cin >> z;
if( z == '+' )
{
cout<<" Result: "<< a << " + "<< b <<" = "<<a+b<<"\n";
goto intrebare;
}
else if( z == '-')
{
cout<<" Result: "<< a << " - "<< b <<" = "<<a-b<<"\n";
goto intrebare;
}
else if( z == '*')
{
cout<<" Result: "<< a << " * "<< b <<" = "<<a*b<<"\n";
goto intrebare;
}
else if( z == '/')
{
cout<<" Result: "<< a << " / "<< b <<" = "<<a/b<<"\n";
goto intrebare;
}
else
{
cout<<" Invalid sign!!"<<endl;
intrebare:
cout<<" Do you whant another try?Y/N: ";
cin>> z;
}
}while((z == 'y')&& !(z =='n'));
system("pause");
return 0;
}
antiRTFM wrote:adrian++
Excellent job!
ramononline wrote:antiRTFM wrote:adrian++
Excellent job!
bad program.... i entered " n " at begining of program and it crashed ...closed window berfore stoping program.... caused somthing to malfunction in ap32 .... my fault also but now im upset.... so beware every one else.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
char response;
int y;
int z;
cout << "input the 1st number:";
cin >> y;
cout << "input the action you would like to take \n";
cin >> response;
cout << "input the 2nd number";
cin >> z;
if (response == '+')
{cout << y << "+" << z << "=" << endl <<"the answer is:" << y + z;}
if (response == '-')
{cout << y << "-" << z << "= \n" << "the answer is:" << y - z;}
if (response == '*')
{cout << y << "*" << z << "=" << endl << "the answer is:" << y * z;}
if (response == '/')
{cout << y << "/" << z << "= \n" << endl << "the answer is:" << y / z;}
cout << endl;
cout << " press any letter and enter to exit the progam:";
char f;
cin >> f;
return 0;
}// just a simple calculator by: Sawm
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
void addition()
{
int long firstNumber, secondNumber, total;
cout<<"\n Welcome to the ADDITION calculator who will add 2 numbers of your choice.\n\n\n\n\n\n\n\n\n\n\n\n"<<endl;
cout<<" First Number:";
cin>> firstNumber;
cout<<" + \n";
cout<<" Second Number:";
cin>> secondNumber;
cout<<"\n\n\n";
cout<<"Awnsser:";
total = firstNumber + secondNumber;
cout<<"\n"<< firstNumber <<" + "<< secondNumber << " = " << total ;
}
void substraction()
{
float firstNumber, secondNumber, total;
cout<<"\nWelcome to the SUBSTRACTION calculator who will substract 2 numbers of your choice.\n\n\n\n\n\n\n\n\n\n\n\n"<<endl;
cout<<" First Number:";
cin>> firstNumber;
cout<<" - \n";
cout<<" Second Number:";
cin>> secondNumber;
cout<<"\n\n\n";
cout<<"Awnsser:";
total = firstNumber - secondNumber;
cout<<"\n"<< firstNumber <<" - "<< secondNumber << " = " << total ;
}
void multiplication()
{
float firstNumber, secondNumber, total;
cout<<"\nWelcome to the MULTIPLICATION calculator who will multiply 2 numbers of your choice.\n\n\n\n\n\n\n\n\n\n\n\n"<<endl;
cout<<" First Number:";
cin>> firstNumber;
cout<<" x \n";
cout<<" Second Number:";
cin>> secondNumber;
cout<<"\n\n\n";
cout<<"Awnsser:";
total = firstNumber * secondNumber;
cout<<"\n"<< firstNumber <<" x "<< secondNumber << " = " << total ;
}
void divide()
{
float firstNumber, secondNumber, total;
cout<<"\n Welcome to the DIVISION calculator who will divide 2 numbers of your choice.\n\n\n\n\n\n\n\n\n\n\n\n"<<endl;
cout<<" First Number:";
cin>> firstNumber;
cout<<" / \n";
cout<<" Second Number:";
cin>> secondNumber;
cout<<"\n\n\n";
cout<<"Awnsser:";
total = firstNumber / secondNumber;
cout<<"\n"<< firstNumber <<" / "<< secondNumber << " = " << total ;
}
int main()
{
string restart = "y";
do
{
int choseThePath;
cout<<"chose what you whould like to do :)"<<endl;
cout<<"1. Addition"<<endl;
cout<<"2. Substraction"<<endl;
cout<<"3. Division"<<endl;
cout<<"4. Multiplication"<<endl;
cout<<"\n and you chose :";
cin>> choseThePath;
//addition path :D
if ( choseThePath == 1)
{
//dont bother this is useles in script lol its copy paste material was bored and wondering how people did stationary stuf if you know hit me up :)
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[ ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|| ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||| ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||||]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[LOADING DONE]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
Sleep(900);
addition();
}
//substraction path
if ( choseThePath == 2)
{
//dont bother this is useles in script lol was bored :)
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[ ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|| ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||| ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||||]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[LOADING DONE]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
Sleep(900);
substraction();
}
//division path
if( choseThePath == 3 )
{
//dont bother this is useles in script lol was bored :)
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[ ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|| ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||| ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||||]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[LOADING DONE]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
Sleep(900);
divide();
}
//multiplication path
if ( choseThePath == 4 )
{
//dont bother this is useles in script lol was bored :)
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[ ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|| ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||| ]";
Sleep (500);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||| ]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||||]";
Sleep (100);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[LOADING DONE]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
Sleep(900);
multiplication();
}
cout<<"\n\nwould you like to reset calcularor? (y/n):";
cin>>restart;
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}while ( restart =="y" );
}
#include <iostream>
using namespace std;
int main()
{
int first; //first number chose.
int second; //second number chose.
char oppps; //operator chose.
int answer; //answer at end.
char exit; //wether you want to exit or not.:)
cout << "welcome to our basic calculator\n"; //message.
cout << "please enter a number\n"; //message .
cin >> first; //first number entered and stored in this for further use.
cout << "please enter a second number which you would like to +,-,/ or * \n"; // mesage.
cin >> second; // stored second number within this for further use.
cout << "please enter a operator e.g: +, -, *, / \n"; //message about operator.
cin >> oppps;
if(oppps == '+') {
cout << first;
cout << "+";
cout << second;
cout << "=";
cout << first+second;
}else
if(oppps == '-') {
cout << first;
cout << "-";
cout << second;
cout << "=";
cout << first-second;
}else
if(oppps == '*') {
cout << first;
cout << "*";
cout << second;
cout << "=";
cout << first*second;
}else
if(oppps == '/') {
cout << first;
cout << " / ";
cout << second;
cout << " = ";
cout << first/second;
cout << " and the remainder would be "; cout << first%second;
}else{
cout << "invalid sign";
}
cout << "\n would you like to continue or leave? \n"; //message
cout << "\n press 'x' to stay and anything else to leave :) \n"; //message
cin >> exit;
if (exit == 'x') {
main();
} else {
return 0;
}
}
Users browsing this forum: No registered users and 0 guests