You are on page 1of 18

MCSL-017: C Programing and Assembly Language Lab

SAI MADHAN
MCA | SEMESTER 1
REGISTER NO: 190951144
January - 2019
MCSL-017: C and Assembly Language Programing

Assignment Code
MCA (1)/L017/Assignment/2018-19
MCSL-017: C Programing and Assembly Language Lab

Banking Application With C Programing

Problem Statement
To create a Banking Application to minimize workloads and ensure
record maintainability and to provide faster services.

Application Features
This application allows employees to
A. Create Accounts for customers
B. View Account details of a customer
C. Modify/Update customer details
D. Delete Records

Source Code

#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>

/* Structure declaration */
struct Account
{
char CustomerName[50];
long int AccountNo;
char AccountType[15];
char Phone[12];
MCSL-017: C Programing and Assembly Language Lab

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)
{

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");
MCSL-017: C Programing and Assembly Language Lab

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");
}
}
}
MCSL-017: C Programing and Assembly Language Lab

/* Input customer details from the user */


void InsertRecord()
{
pos++;
printf("\n Enter the name of customer : ");
fflush(stdin);
gets(records[pos].CustomerName);
printf("\n Account Number is : ");
records[pos].AccountNo=rand();
printf("%ld",&records[pos].AccountNo);
printf("\n Enter the account type Savings/Current : ");
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 Deposit amount : ");
fflush(stdin);
scanf("%ld",&records[pos].Balance);
printf("\n Enter the joining date : ");
MCSL-017: C Programing and Assembly Language Lab

fflush(stdin);
gets(records[pos].JoinDate);
printf("Account Creation successful");
}

/* Display the details of a customer based on account number */


void DisplayRecord()
{
long int 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);
MCSL-017: C Programing and Assembly Language Lab

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 int 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");
MCSL-017: C Programing and Assembly Language Lab

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 */
MCSL-017: C Programing and Assembly Language Lab

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");
}
Printf(“success!”);
break;
}
}
if(count == 0)
printf("\n Record not found !");
MCSL-017: C Programing and Assembly Language Lab

/* Delete the record of a customer based on account number */


void DeleteRecord()
{
long int 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);
MCSL-017: C Programing and Assembly Language Lab

}
pos--;
printf(“Success!”);
break;
}
}
if(count == 0)
printf("\n Record not found !");
}

Sample Output
1. Creating Account

Press 1 for creating a new record

Press 2 for Reading/Listing an existing record

Press 3 for Modify a particular record

Press 4 for Delete a particular record

Press 5 for exit

Enter your choice: 1

Enter Customer Name: xyz

Account Number is: 4227284

Enter Account type savings/current: Savings

Enter Phone number: 1234567890

Enter address of Customer: No.1, Xyz Street, z area, Chennai, Tamilnadu, India

Enter name of Nominee: ABC

Enter a Deposit amount: 2000

Enter Joining Date: 11-04-19

Account created successfully!


MCSL-017: C Programing and Assembly Language Lab

2. Viewing an existing record

Press 1 for creating a new record

Press 2 for Reading/Listing an existing record

Press 3 for Modify a particular record

Press 4 for Delete a particular record

Press 5 for exit

Enter your choice: 1

Enter the Account Number: 4227284

Customer name : xyz

Account Number : 4227284

Account Type : Savings

Contact Number : 1234567890

Contact Address : No.1, Xyz Street, Zyx area, Chennai, TamilNadu, India

Nominee Name : ABC

Account Balance : 2000

Joining Date : 11-04-19

3. To Modify Account info

Press 1 for creating a new record

Press 2 for Reading/Listing an existing record

Press 3 for Modify a particular record

Press 4 for Delete a particular record

Press 5 for exit

Enter your choice: 3

Press 1 for edit customer name

Press 2 for edit Account type

Press 3 for edit customer contact number

Press 4 for edit customer address

Press 5 for edit Nominee name

Press 6 for edit Account balance

Enter our choice: 3


MCSL-017: C Programing and Assembly Language Lab

Enter the phone number: 0987654321

Success!

4. Delete Record

Press 1 for creating a new record

Press 2 for Reading/Listing an existing record

Press 3 for Modify a particular record

Press 4 for Delete a particular record

Press 5 for exit

Enter your choice: 4

Enter Account Number: 4227284

Success!

Press 1 for creating a new record

Press 2 for Reading/Listing an existing record

Press 3 for Modify a particular record

Press 4 for Delete a particular record

Press 5 for exit

Enter your choice: 2

Enter Account Number: 4227284

No Records found!
MCSL-017: C Programing and Assembly Language Lab

Assembly Language

1. A. Display System Time

DATA SEGMENT

MSG1 DB 'CURRENT TIME IS : $'


HR DB ?
MIN DB ?
SEC DB ?
MSEC DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX, DATA
MOV DS, AX
MOV AH,2CH ; TO GET SYSTEM TIME
INT 21H
MOV HR, CH ; CH -> HOUR
MOV MIN, CL ; CL -> MINUTES
MOV SEC, DH ; DH -> SECONDS
MOV MSEC, DL ; DL -> 1/100TH SECOND
LEA DX, MSG1 ; DISPLAY MSG1
MOV AH, 09H
INT 21H
MOV AL, HR ; IF AL=0D AAM WILL SPLIT THE NIBBLES INTO AH AN
D AL
AAM ; SO AH=01 AND AL=03
MOV BX, AX
CALL DISPLAY ; DISPLAY HOURS
MOV DL, ':' ; DISPLAY ':' AFTER DISPLAYING HOUR
MOV AH, 02H
INT 21H
MOV AL, MIN
AAM
MOV BX, AX
MCSL-017: C Programing and Assembly Language Lab

CALL DISPLAY ; DISPLAY MINUTES


MOV DL, ':' ; DISPLAY ':' AFTER DISPLAYING MINUTES
MOV AH, 02H
INT 21H
MOV AL, SEC
AAM
MOV BX, AX
CALL DISPLAY ; DISPLAY SECONDS
MOV DL, '.' ; DISPLAY '.' AFTER DISPLAYING SECONDS
MOV AH, 02H
INT 21H
MOV AL, MSEC
AAM
MOV BX, AX
CALL DISPLAY ; DISPLAY 1/100TH SECONDS
MOV AH, 4CH
INT 21H
DISPLAY PROC NEAR
MOV DL, BH
ADD DL, 30H ; DISPLAY BH VALUE
MOV AH, 02H
INT 21H
MOV DL, BL
ADD DL, 30H ; DISPLAY BL VALUE
MOV AH, 02H
INT 21H
RET
DISPLAY ENDP
CODE ENDS
END START
MCSL-017: C Programing and Assembly Language Lab

1. B. Multiply two 16 bit numbers

Source Code
data segment
a dw 1234h
b dw 5678h
c dd ?
data ends

code segment
assume ds:data, cs:code
start:
mov ax,data
mov ds,ax
mov ax,a
mov bx,b
mul bx
mov word ptr c,ax
mov word ptr c+2,dx
int 3
code ends
end start
MCSL-017: C Programing and Assembly Language Lab

1. C. Adding two numbers

Source Code
data segment
a db 09h
b db 02h
c dw ?
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov al,a
mov bl,b
add al,bl
mov c,ax
int 3
code ends
end start
MCSL-017: C Programing and Assembly Language Lab

1. D. Move immediate data to register

Immediate data means any constant or assigning value to the operands.

Source Code
MOV AL, 10
BYTE_VALUE DB 1500 ; A byte value is defined
WORD_VALUE DW 300 ; A word value is defined
ADD BYTE_VALUE, 65 ; An immediate operand 65 is added
MOV AX, 45H ; Immediate constant 45H is transferred toAX

You might also like