So to pass the number through your code, you can just use function arguments... You could potentially use global variables as well, but that is much more susceptible to bugs/less safe generally. This is the 2 in action in pseudocode like you asked:
OPTION 1: Passing the account balance as function arguments:
Code:
struct Customer{
int account_balance;
};
int main(){
/*This is just an example, you can set up the random number to your liking of course*/
srand(time(NULL));
int accountBalance = rand();
struct Customer *user = malloc(sizeof(struct Customer)); //New up a new customer struct on the heap
user->account_balance = accountBalance;
Now, for the rest of the application, you can simply code your functions to accept a struct Customer *ptr as an argument and that way you will have that generated account balance until the program is terminated. You could simplify it without a struct as well, but I used a struct in case you had some other data you wanted to pass around because that'll make it easier. Don't forget to free(user) when appropriate as well after you no longer need it. Here's an example of usage:
Code:
//In header
void depositBalance(struct Customer *cPtr);
//In .c file:
void depositBalance(int amountToDeposit, struct Customer *cPtr){
cPtr->account_balance += amountToDeposit;
printf("Transaction complete!\n");
return;
}
Option 2 is as he mentioned above, use a global variable which is literally just assigning something like int accountBalance = rand() outside of any function, now all functions in the program can access that variable and read/modify it.