1
An agency in a small town has a maximum of 10,000 clients. Develop an algorithm that can enter each client’s account number, name and balance. The algorithm must print all accounts, their balances and one of the messages: positive / negative. Typing ends when you type -999 for the account number or when it reaches 10,000. At the end, the algorithm should show the total of clients with negative balance, the total of clients of the agency and the balance of the agency.)
Well, I soon thought of using a data structure with the necessary variables to store the information requested from the client N times, each time from a different client. Well, here’s my code.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
typedef struct clientes
{
char nome[50];
int conta;
int saldo;
} clientes;
struct clientes cadastro_cliente (clientes x);
int main()
{
setlocale(LC_ALL,"");
struct clientes x[1000];
int i;
for(i = 0; i < 5; i++)
{
cadastro_cliente(clientes x[i]);
}
}
struct clientes cadastro_cliente (clientes x);
{
printf("Insira o nome completo do titular da conta: ");
scanf("%s", &x.nome);
printf("Insira o número da conta: ");
scanf("%i", &x.conta);
printf("Insira o saldo da conta: ");
scanf("%i", &x.saldo);
}
The code returns me an error when executing, an expected error because I have no knowledge of how to pass a structure to a function that would be called N times. I got to this point watching a video on Youtube but I can not ask questions. How would pass a structure to function and call the same in main()
whenever requested by the user?