diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 00000000..b5bf693b --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,23 @@ +name: Build C++ + +on: + push: + branches: "**" + pull_request: + branches: [ main ] + +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 diff --git a/README.md b/README.md new file mode 100644 index 00000000..2bc7ccd2 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +[![Build C++](https://github.com/oerivas-star/MyFirstExample/actions/workflows/actions.yml/badge.svg)](https://github.com/oerivas-star/MyFirstExample/actions/workflows/actions.yml) + +HELLO +my name is Omar nice to meet all diff --git a/main.cpp b/main.cpp index 5411e7a3..7f7c18e4 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,10 @@ int main() cout << "Addition: " << x + y << endl; cout << "Subtraction: " << x - y << endl; cout << "Multiplication: " << x * y << endl; + if (y == 0){ + cout << "Cannot divide by 0" << endl; + return 1; + } cout << "Division: " << x / y << endl; cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl;