I'm supposed to check for dividing by 0, but every time I try to get it to say error can't divide by 0, it just crashes
again it's super simple. about the 3rd week of class.
I need to check for 0.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream outFavs;
outFavs.open("bartlett_txt.txt", ios::app);
int a; //used the int values for the first values
int b;
int c;
int num1, num2;
int integer;
cout << "Enter first number: ";
cin >> num1;
cout << "Enter Second Number: ";
cin >> num2;
if (num2==0)
cout << "can't divide by 0" << endl;
else
cout << "division is: " << num1/num2 << endl;
cout << "remainder is: " << num1 % num2 << endl;
if (num1 > num2)
{
cout << "num1 larger" << endl;
}
else if (num2 > num1)
{
cout << "num2 larger" << endl;
}
else
{
cout << "num1 is equal to num2" << endl;
}
cout << "Enter two numbers: " << endl;
cin >> a >> b;
c = a + b;
cout << "Value of Addition is : " << c << endl;
c = a - b;
cout << "Value of Subtraction is : " << c << endl;
c = a * b;
cout << "Value of Multiplication is : " << c << endl ;
c = a / b;
cout << "Value of Division is : " << c << endl ;
c = a % b;
cout << "Value of Percentage is : " << c << endl ;
c = a++;
cout << "Value of Post-Increment is : " << c << endl ;
c = a--;
cout << "Value of Post-Decrement is : " << c << endl ;
//// couldn't figure out how to correctly space them apart, and to write that the new line was going to represent the values of the decimals.
cout << "Enter two numbers: " << endl;
cin >> x >> y;
cout << "Please enter an integer" << endl;
cin >> integer;
//determine if integer is odd or even
if ( integer % 2==0 )
// if the integer when divided by 2 has no remainder its even.