-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/source/main'
- Loading branch information
Showing
18 changed files
with
475 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Make Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libtool-bin autoconf automake cmake g++ pkg-config unzip gettext curl -y | ||
- name: Install Neovim | ||
run: | | ||
sudo snap install nvim --classic | ||
- name: Install Plenary | ||
run: | | ||
git clone https://github.com/nvim-lua/plenary.nvim.git | ||
mkdir -p .local/share/nvim/lazy/ | ||
mv plenary.nvim .local/share/nvim/lazy/ | ||
- name: Tests | ||
env: | ||
XDG_CONFIG_HOME: ${{ github.workspace }}/.config | ||
XDG_DATA_HOME: ${{ github.workspace }}/.local/share | ||
XDG_STATE_HOME: ${{ github.workspace }}/.local/state | ||
XDG_CACHE_HOME: ${{ github.workspace }}/.cache | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
// Structure to represent an account | ||
typedef struct { | ||
int accountNumber; | ||
float balance; | ||
} Account; | ||
|
||
// Function to create a new account | ||
Account* createAccount(int accountNumber, float initialBalance) { | ||
Account* newAccount = (Account*)malloc(sizeof(Account)); | ||
if (!newAccount) { | ||
printf("Memory error\n"); | ||
return NULL; | ||
} | ||
newAccount->accountNumber = accountNumber; | ||
newAccount->balance = initialBalance; | ||
return newAccount; | ||
} | ||
|
||
// Function to deposit money into an account | ||
void deposit(Account* account, float amount) { | ||
if (amount > 0.0f) { | ||
account->balance += amount; | ||
printf("Deposited $%.2f into account %d\n", amount, account->accountNumber); | ||
} else { | ||
printf("Invalid deposit amount: $%.2f\n", amount); | ||
} | ||
} | ||
|
||
// Function to withdraw money from an account | ||
void withdraw(Account* account, float amount) { | ||
if (amount > 0.0f && amount <= account->balance) { | ||
account->balance -= amount; | ||
printf("Withdrawn $%.2f from account %d\n", amount, account->accountNumber); | ||
} else { | ||
printf("Invalid withdrawal amount: $%.2f\n", amount); | ||
} | ||
} | ||
|
||
// Function to display account information | ||
void printAccountInfo(Account* account) { | ||
printf("Account Number: %d\nBalance: $%.2f\n", account->accountNumber, account->balance); | ||
} | ||
|
||
int main() { | ||
Account* account = createAccount(12345, 1000.00f); | ||
|
||
deposit(account, 500.00f); | ||
withdraw(account, 200.00f); | ||
printAccountInfo(account); | ||
|
||
free(account); | ||
return 0; | ||
} | ||
|
Oops, something went wrong.