Вы находитесь на странице: 1из 9

Course Code : MCSL-017

Course Title : C and Assembly Language Programming

Question 1: Write an interactive program in C language to manage the working of a Construction Company.
Implement and manage the records with suitable data structures using the file handling concepts that keeps track of
various projects of the company and their states (proposal, installation, maintenance, yearly contract etc.), the
business turnovers of the company, salaries of the employees, present assignments of the employees and details of
the clients. The application should be designed user-friendly.

Hint:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>

struct EmpData //structure to store employee details


{
int empid;
char ename[60];
float salary;
float da,ta;
int pid;
}emp;
struct project // structure to store project details
{
int pid;
char pname[60];
}pro;

main()
{
FILE *fp;
FILE *fp1;
char ans, choice, ch1;
int rec,st;
rec=sizeof(emp);
fp=fopen("d:emp.dat","a+"); //file to store tranactions
do
{

clrscr();
gotoxy(5,5);
textcolor(4);
//Menu to display options to the users
printf("\nEmployee Management System");
printf("\n\n");
printf("\n\t\t\t[A]Add record:");
printf("\n");
printf("\n\n[E]Employee Add record:");
printf("\n\n[P]Project Add record:");

printf("\n\n");
printf("\n\t\t\t[L]List Record:");
printf("\n\t\t\t[S]Search Record:");

www.solutioncab.com (a complete solution site)


printf("\n\t\t\t[D]Delete Record:");
printf("\n\t\t\t[X]Exit System:");
printf("\n\t\t\tEnter Your Choice:");
fflush(stdin);
scanf("%c",&choice);
if(choice=='a'||choice=='A')
{
printf("\nEmployee Management System");
printf("\n\n");
printf("\n\n[E]Employee Add Record:");
printf("\n\n[P]Project Add Record:");
printf("\n\n");
printf("\n\t\tEnter Your Choice:");
fflush(stdin);
scanf("%c",&choice);
if(ch1=='e'||ch1=='E')
{
clrscr();
gotoxy(25,2);
textcolor(6);
printf("\nEmployee Mangement System");
printf("\n\n");
fseek(fp,0,SEEK_END);
printf("\n\n\nEnter Employee ID:");
scanf("%d",&emp.empid);
printf("\n\n\nEnter Employee Name:");
gets(emp.ename);
printf("\n\n\nEnter Employee Salary:");
scanf("%f",&emp.salary);
printf("\n\nEnter Project Status:");
scanf("%d",&emp.pid);
emp.da=(emp.salary*0.15);
emp.ta=(emp.salary*0.10);
fwrite(&emp,rec,1,fp);
fclose(fp);
}
else
{
fp=fopen("d:emp.dat","a+");
clrscr();
gotoxy(25,2);
textcolor(6);
printf("\nEmployee Mangemeent System");
printf("\n\n");
fseek(fp,0,SEEK_END);
printf("\n\n\nEnter Project ID:");
scanf("%d",&pro.pid);
printf("\n\n\nEnter Project Name:");
gets(pro.pname);
fwrite(&pro,rec,1,fp);
fclose(fp);
}
}
else if(choice=='L'||choice=='l')
{
clrscr();

www.solutioncab.com (a complete solution site)


gotoxy(25,2);
textcolor(6);
printf("\nEmployee Management System");
printf("\n\n");
rewind(fp);
printf("\nEmpID\tName\tSalary\tTA\tDA\tProject Total");
printf("\n----------------------------------------------\n");
while(fread(&emp,rec,1,fp)==1)
{

printf("\n%d\t\t%s\t\t%2f\t\t%2f\t\t%d\t\t%2f",emp.empid,emp.ename,emp.salary,emp.ta,emp.da,emp.pid,(emp.sala
ry+emp.ta+emp.da));
}
getch();
}
else if(choice=='S'||choice=='s')
{
int no,s=0;
clrscr();
printf("\nEnter no to search:");
fflush(stdin);
scanf("%d",&no);
clrscr();
gotoxy(25,2);
textcolor(6);
printf("\nEmployee Management System");
printf("\n\n");
rewind(fp);
printf("\nEmp ID\tName\tSalary\tTA\tDA\tTotal");
printf("\n---------------------------------------\n");
while(fread(&emp,rec,1,fp)==1)
{
if(no==emp.empid)
{

printf("\n%d\t\t%s\t\t%2f\t\t%2f\t\t%2f\t\t%d\t\t%2f",emp.empid,emp.ename,emp.salary,emp.ta,emp.da,emp.pid,(e
mp.salary+emp.ta+emp.da));
s++;
break;
}
if(s==0)
printf("\nNO DATA FOUND");
getch();
}

}
gotoxy(25,40);
printf("\nDo you want to continue...(Y or N)");
scanf("%c",&ans);
}while(ans=='y'|ans=='Y');
printf("BYE..!!");
getch();
return 0;
}

www.solutioncab.com (a complete solution site)


OUTPUT SCREENS

MAIN SCREEN

ADD PROJECT SCREEN

www.solutioncab.com (a complete solution site)


SEARCH SCREEN

Section 2: Assembly Language Programming Lab


Question 2:

(a) Write a program in 8086 assembly language that converts two four digit numbers
into its equivalent packed BCD. Also, it compares the numbers and displays the larger number. In case both
the numbers are same then zero can be displayed.

Hint: MY_DATA SEGMENT

NUM1 DB'1234'
NUM2 DB'1235'
UNPK_NUM1 DW?
UNPK NUM2 DW?
MAX_NUM DW?
MY_DATA ENDS
MY_CODE SEGMENT

ASSUME CS:MY_CODE, DS:MY_DATA


START: MOV AX,MY_DATA
MOV DS, AX
LEA SI, NUM1
MOV AH,[SI]
INC SI
MOV AL,[SI]
AND AH, 0FH
ROL AH, 0FH
ROL AH, 04H

www.solutioncab.com (a complete solution site)


OR AH, AL
INC SI
MOV BH, [SI]
INC SI
MOV BL, [SI]
AND BH, 0FH
AND BL, 04H
ROL BH, 04H
OR BH, BHL
MOV AL, BH
MOV UNPK_NUM1, AX
LEA SI, NUM2
MOV AH, [SI]
AND AH, 0FH
AND AL, 0FH
AND AH, 04H
ROL AH, 04H
OR AH, 04H
INC SI

MOV BH, [SI]


INC SI
MOV BL, [SI]
AND BH, 0FH
AND BL, 0FH
ROL BH, 04H
OR BH, 04H
MOV AL, BH
MOV UNPK_NUM2, AX
CMP AX, BX
JA LI
MOV MAX_NUM, BX
JMP L2
L1: MOV MAX_NUM, AX
L2: INT 21H
MY_CODE ENDS

END START

(b) Write a program in 8086 assembly language that accept a string from the keyboard and then reverses a
string using stack. The string can be assumed to be available in the data segment. The results are also to be
created in the data segment.
Hint:
PTRSTR MACRO MS
MOV AH, 09H
LEA DX, MS
INT 21H
ENDM

DATA SEGMENT

STR1 DB 20
DB 20 DUP('$)
CRLF DB 0AH,0DH,$
STR2 DB 20

www.solutioncab.com (a complete solution site)


DB 0
DB 20 DUP('$')
MSG1 DB"ENTER A STRING:$"
MSG2 DB"REVERSE OF GIVEN STRING:$"
DATA ENDS

STACK_SEG SEGMENT

DB 25 DUP(?)
TOP_STACK LABEL BYTE
STACK_SEG ENDS

CODE SEGMENT

ASSUME CS: CODE, DATA, ES: DATA, SS: STACK_SEG


START
MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV AX, STACK_SEG

PTRSTR MSG1

MOV AH, 0AH


LEA DX, STR1
INT 21H
MOV CX, 00
MOV DL, 00

LEA SI, STR1+1


LEA DI, STR2+2
MOV BL,'$'

L2: PUSH[SI]
CMP[SI], BL
JE L1
INC SI

JMP L2
L1: POP AX
MOV[DI], AX
CMP AL, BL
JE L3
JMP L2
L3: PTRSTR CRLF
PTRSTR MSG2
PTRSTR STR2+2

MOV AH, 4CH


INT 21H

CODE ENDS
END START

www.solutioncab.com (a complete solution site)


(c ) Write a program in 8086 assembly language program to divide a 16-bit number stored in memory locations
2501 and 2502 H with an 8-bit divisor stored in the memory location 2503 H. Store the quotient in 2504 H
and remainder in 2505 H.
Hint:
MY DATA SEGMENT
BLANK_MEMORY_BLOCK DB 2501H DUP(?)
DIVIDEND DW 105H; 16 BIT NUMBER STORED ON 2501H AND 2502
DIVISOR DB 10H ; 8 BITDIVISOR ON 2503H
QUOTIENT DB? ; 8 BIT QUOTIENT ON 2504H
REMEAINDER DB?
MY_DATA ENDS

MY_CODE SEGMENT

ASSUME CS: MY_CODE, DS: MY_DATA


START: MOV AX, MY_DATA
MOV DS, AX
MOV AX, DIVIDENT
MOV BL, DIVISOR
DIV BL
MOV QUOTIENT, AL
MOV REMAINDER, AH
INT 21H
MY_CODE ENDS
END START

(d). Write a program in 8086 assembly language to evaluates 6*(x^2) + 5x + 9 if flag = = 1 or 4*(x^2) + 7 if flag = =
0. Assume x is a 16-bit unsigned integer.

Hint:
MY_DATA SEGMENT

X DW 2H
FLAG DB 0
RESULT DW?

MY_DATA ENDS

MY_CODE SEGMENT

ASSUME CS: MY_CODE, DS: MY_DATA


START: MOV AX, MY_DATA
MOV DS, AX

MOV AL, FLAG


CMP AL, 0
JZ L1
MOV AX, X
MUL AX
MOV BL, 6
MUL BL

MOV BX, AX
MOV CL, 5

www.solutioncab.com (a complete solution site)


MOV AX, X
MUL CL
ADD AX, 9
ADC AX, BX
JMP L2
L1: MOV AX, X
MUL AX
MOV BL, 4MUL BL
ADD AX, 7
L2: MOV RESULT, AX
INT 21H
MY_CODE ENDS

END START

www.solutioncab.com (a complete solution site)

Вам также может понравиться