How can one write a function in C language for the statistics of the average of
ID: 3661593 • Letter: H
Question
How can one write a function in C language for the statistics of the average of balances in all accounts using this struct below:typedef struct { char surName[SURNAMESIZE]; char lastName[LASTNAMESIZE]; char accNumber[ACCNUMBER]; float balance; } AccReg; AccReg initAccount(char accountNr[], char theSurName[], char theLastName[], float theBalance)/*ett konto skapas*/ { AccReg anAcc; strcpy(anAcc.accNumber,accountNr); strcpy(anAcc.surName,theSurName); strcpy(anAcc.lastName,theLastName); anAcc.balance=theBalance; return anAcc; }
Explanation / Answer
BELOW ARE THE CODE :
#include <stdio.h>
#include <string.h>
struct customer
{
*// STRUCTURE DEFINE//*
char surName[SURNAMESIZE];
char lastName[LASTNAMESIZE];
char accNumber[ACCNUMBER];
float balance;
};
typedef struct customer CUST
{ char surName[SURNAMESIZE];
char lastName[LASTNAMESIZE];
char accNumber[ACCNUMBER];
float balance;
}
void show();
int main()
{ *// ENTERING VALUE//*
strcpy(anAcc.accNumber,”axe12345”);
strcpy(anAcc.surName,”Jame”);
strcpy(anAcc.lastName,”Alice”);
anAcc.balance=1000;
show();
getch();
return 0;
}
void show();
{
//*DISPLAY REGISTRATION//*
printf("Account Number is: %S ", CUST.accNumber);
printf(" SurName is: %s ", CUST.surName);
printf(" LastName is: %s ", CUST.lastName);
printf(" Balance is: %f ", CUST.balance);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.