diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..4f171b56 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +name: Build C++ + +on: + push: + branches: [ main , ci/cd ] + +jobs: + install: + runs-on: ubuntu-latest + steps: + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y -f build-essential g++ cmake + + build: + needs: install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build project + run: g++ -std=c++17 main.cpp \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..0f115060 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +[![Build C++](https://github.com/RezDead/MyFirstExample/actions/workflows/build.yml/badge.svg)](https://github.com/RezDead/MyFirstExample/actions/workflows/build.yml) diff --git a/main.cpp b/main.cpp index 5411e7a3..496eda3e 100644 --- a/main.cpp +++ b/main.cpp @@ -7,7 +7,7 @@ using std::cout; int main() { - cout << "THE FIRST EXAMPLE MATH DISPLAY!\n"; + cout << "THE FIRST EXAMPLE MATH DISPLAY!\n" cout << "Hi, please enter two whole numbers: "; int x,y; @@ -16,7 +16,10 @@ int main() cout << "Addition: " << x + y << endl; cout << "Subtraction: " << x - y << endl; cout << "Multiplication: " << x * y << endl; - cout << "Division: " << x / y << endl; + if (y == 0) + cout << "Dividing by zero is not a number" << endl; + else + cout << "Division: " << x / y << endl; cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;