diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7a258089 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +name: Build C++ + +on: + push: + branches: + - '**' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install compiler + run: | + sudo apt-get update + sudo apt-get install -y g++ + + - name: Build project + run: g++ -std=c++17 -O2 -Wall -Wextra -o app main.cpp + diff --git a/README.md b/README.md new file mode 100644 index 00000000..c262ff64 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +[![Build C++](https://github.com/aakhan10/MyFirstExample/actions/workflows/build.yml/badge.svg)](https://github.com/aakhan10/MyFirstExample/actions/workflows/build.yml) + +# My First Example + diff --git a/main.cpp b/main.cpp index 5411e7a3..2eb4ec8c 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,14 @@ int main() cout << "Addition: " << x + y << endl; cout << "Subtraction: " << x - y << endl; cout << "Multiplication: " << x * y << endl; + if (y == 0) + { + cout << "Division: Dividing by zero is not a number." << endl; + } + else + { + cout << "Division: " << x / y << endl; + } cout << "Division: " << x / y << endl; cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl;