MCSL-017 ASSIGNMENT SOLUTION (2018-19)

If you have any queries please leave a message here
Your Message
×


Section 1: C Programming Lab

Question 1 :

Write an interactive program in C language to create an application program for a cooperative bank to maintain the customers’ database. This application should have menu options like below :

Each customer record should have Customer Name, Account Number, Account Type, Telephone/Mobile, Address, Nominee Name, Account Balance, Date of Joining, etc. The application should be designed user-friendly.

Answer : -

#include<stdio.h>

/* Structure declaration */
struct Account
{
char CustomerName[50];
unsigned long AccountNo;
char AccountType[15];
char Phone[12];
char Address[100];
char NomineeName[50];
long Balance;
char JoinDate[12];
};

/* Global variables declaration */
struct Account records[10];
int pos=-1, i, j, count;

/* Global functions declaration */
void InsertRecord();
void DisplayRecord();
void ModifyRecord();
void DeleteRecord();

/* main( ) function */
void main()
{
int choice;
while(1)
{
clrscr();
printf("\n Press 1 for Creating a new record");
printf("\n Press 2 for Reading/Listing an existing record");
printf("\n Press 3 for Modify a particular record");
printf("\n Press 4 for Delete a particular record");
printf("\n Press 5 for exit");
printf("\n Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
InsertRecord();
break;
case 2:
DisplayRecord();
break;
case 3:
ModifyRecord();
break;
case 4:
DeleteRecord();
break;
case 5:
exit(0);
default :
printf("\n\n\n Wrong Input");
}
}
}

/* Input customer details from the user */
void InsertRecord()
{
pos++;
printf("\n Enter the name of customer : ");
fflush(stdin);
gets(records[pos].CustomerName);
printf("\n Enter the account number : ");
fflush(stdin);
scanf("%ld",&records[pos].AccountNo);
printf("\n Enter the account type : ");
fflush(stdin);
gets(records[pos].AccountType);
printf("\n Enter the phone number : ");
fflush(stdin);
gets(records[pos].Phone);
printf("\n Enter the address of customer : ");
fflush(stdin);
gets(records[pos].Address);
printf("\n Enter the name of nominee : ");
fflush(stdin);
gets(records[pos].NomineeName);
printf("\n Enter the current account balance : ");
fflush(stdin);
scanf("%ld",&records[pos].Balance);
printf("\n Enter the joining date : ");
fflush(stdin);
gets(records[pos].JoinDate);
}

/* Display the details of a customer based on account number */
void DisplayRecord()
{
long AccNo;
printf("\n Enter the account number : ");
scanf("%ld",&AccNo);
count = 0;
for(i=0;i<=pos;i++)
{
/* Check whether the inputed account number present in the array or not */
if(records[i].AccountNo == AccNo)
{
count++;
printf("\n\n Customer Name \t\t: %s",records[i].CustomerName);
printf("\n\n Account Number \t: %ld",records[i].AccountNo);
printf("\n\n Account Type \t\t: %s",records[i].AccountType);
printf("\n\n Customer Address \t: %s",records[i].Address);
printf("\n\n Contact Number \t: %s",records[i].Phone);
printf("\n\n Nominee Name \t\t: %s",records[i].NomineeName);
printf("\n\n Account Balance \t: %ld",records[i].Balance);
printf("\n\n Joining Date \t\t: %s",records[i].JoinDate);
break;
}
}
if(count == 0)
printf("\n Record not found !");
}

/* Edit customer details */
void ModifyRecord()
{
int c;
long AccNo;
printf("\n Enter the account number : ");
scanf("%ld",&AccNo);
count = 0;
for(i=0;i<=pos;i++)
{
/* Check whether the inputed account number present in the array or not */
if(records[i].AccountNo == AccNo)
{
count++;
printf("\n Press 1 for edit customer name");
printf("\n Press 2 for edit account type");
printf("\n Press 3 for edit customer contact number");
printf("\n Press 4 for edit customer address");
printf("\n Press 5 for edit nominee name");
printf("\n Press 6 for edit account balance");
printf("\n Enter your choice : ");
scanf("%d",&c);
switch(c)
{
/* Update name of the customer (account holder) */
case 1:
printf("\n Enter the name of customer : ");
fflush(stdin);
gets(records[i].CustomerName);
break;
/* Update account type */
case 2:
printf("\n Enter the account type : ");
fflush(stdin);
gets(records[i].AccountType);
break;
/* Update contact details of the customer */
case 3:
printf("\n Enter the phone number : ");
fflush(stdin);
gets(records[i].Phone);
break;
/* Update postal address of the customer */
case 4:
printf("\n Enter the address of customer : ");
fflush(stdin);
gets(records[i].Address);
break;
/* Update name of the nominee */
case 5:
printf("\n Enter the name of nominee : ");
fflush(stdin);
gets(records[pos].NomineeName);
break;
/* Update account balance */
case 6:
printf("\n Enter the current account balance : ");
fflush(stdin);
scanf("%ld",&records[pos].Balance);
break;
default:
printf("Wrong Input");
}
break;
}
}
if(count == 0)
printf("\n Record not found !");
}

/* Delete the record of a customer based on account number */
void DeleteRecord()
{
long AccNo;
printf("\n Enter the account number : ");
scanf("%ld",&AccNo);
count = 0;
for(i=0;i<=pos;i++)
{
/* Check whether the inputed account number present in the array or not */
if(records[i].AccountNo == AccNo)
{
count++;
for(j=i;j<pos;j++)
{
strcpy(records[j].CustomerName, records[j+1].CustomerName);
records[j].AccountNo = records[j+1].AccountNo;
strcpy(records[j].AccountType, records[j+1].AccountType);
strcpy(records[j].Phone, records[j+1].Phone);
strcpy(records[j].Address, records[j+1].Address);
strcpy(records[j].NomineeName, records[j+1].NomineeName);
records[j].Balance = records[j+1].Balance;
strcpy(records[j].JoinDate, records[j+1].JoinDate);
}
pos--;
break;
}
}
if(count == 0)
printf("\n Record not found !");
}

Output



ABOUT US

QuestionSolves.com is an educational website that helps worldwide students in solving computer education related queries.

Also, different software like Visual Studio, SQL Server, Oracle etc. are available to download in different versions.

Moreover, QuestionSolves.com provides solutions to your questions and assignments also.


MORE TOPIC


Windows Command

UNIX Command

IGNOU Assignment Solution

IGNOU Question Paper Solution


WHAT WE DO


Website Devlopment

Training

Home Learning

Provide BCA, MCA Projects

Provide Assignment & Question Paper Solution


CONTACT US


Follow Us