You are on page 1of 12

Q: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 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.

Ans:-

#include<stdio.h>
#include<conio.h>
#include<math.h>

struct EmpData

{
int empid;
char ename[60];
float salary;
float da,ta;
int pid;
}emp;

struct project

{
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+");

do

fflush(stdin). printf("\n\t\t\t[S]Search Record:"). if(ch1=='e'||ch1=='E') { clrscr(). gotoxy(). gotoxy(25. printf("\nEmployee Mangement System"). printf("\n\n"). printf("\n\t\t\t[L]List Record:"). printf("\n\n"). printf("\n\n"). printf("\n\n[E]Employee Add record:"). printf("\n\t\t\t[D]Delete Record:"). scanf("%c".{ clrsc(). scanf("%c".0. fseek(fp.&choice). textcolor(4). printf("\n\t\t\t[A]Add record:").SEEK_END). printf("\n"). printf("\n\t\t\Enter Your Choice:").2).&choice). fflush(stdin). printf("\n\t\t\t[X]Exit System:"). textcolor(6). printf("\n\n[P]Project Add Record:"). printf("\n\n[E]Employee Add Record:"). if(choice=='a'||choice=='A') { printf("\nEmployee Management System"). printf("\nEmployee Management System"). . printf("\n\n"). printf("\n\n[P]Project Add record:"). printf("\n\t\t\tEnter Your Choice:"). printf("\n\n").

rewind(fp).SEEK_END).1.0. fwrite(&pro.&emp. fclose(fp). fclose(fp).rec.ta=(emp. fwrite(&emkp. printf("\n\n\nEnter Project Name:"). } else { fp=fopen("d:\emp.pname).fp)."a+").&emp. printf("\n\nEnter Project Status:").2).rec.salary*0.&emp. scanf("%d".pid).15). printf("\n\n"). fseek(fp.&pro.2). textcolor(6).empid).salary*0. while(fread(&emp. emp.10). textcolor(6). scanf("%f". scanf("%d". clrscr(). printf("\nEmployee Mangemeent System").da=(emp. printf("\n\n").salary).fp). printf("\nEmpID\tName\tSalary\tTA\tDA\tProject Total"). printf("\n\n\nEnter Employee Name:"). printf("\n\n\nEnter Employee Salary:"). gets(pro. printf("\n\n\nEnter Employee ID:"). gets(emp.ename). } } else if(choice=='L'||choice=='l') { clrscr().dat". emp. printf("\n\n\nEnter Project ID:").rec. printf("\n----------------------------------------------\n").fp)==1) . scanf("%d". gotoxy(25. printf("\nEmployee Management System"). gotoxy(25.pid).1.1.

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

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

AL INC SI MOV BH. 04H OR AH. 04H OR BH. BH . 0FH ROL AH. 0FH AND BL. DS:MY_DATA START: MOV AX.MY_DATA MOV DS. [SI] AND BH. Answer: 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. Also it compares that numbers and display the large one. BHL MOV AL. [SI] INC SI MOV BL. 0FH ROL AH. In case the numbers are same then zero can be displayed. 04H ROL BH. AX LEA SI.[SI] INC SI MOV AL.[SI] AND AH.Q:2-(A) Write a program in 8086 assembly language that convert two four digit number into its equivalent packed BCD. NUM1 MOV AH.

NUM2 MOV AH. 04H ROL AH. [SI] INC SI MOV BL. BX JA LI MOV MAX_NUM. AX CMP AX. 04H INC SI MOV BH. 04H OR BH. 04H MOV AL. [SI] AND AH. BX JMP L2 L1: MOV MAX_NUM. BH MOV UNPK_NUM2. 0FH ROL BH. 0FH AND BL. 0FH AND AH. 0FH AND AL.MOV UNPK_NUM1. AX LEA SI. [SI] AND BH. AX L2: INT 21H MY_CODE ENDS END START . 04H OR AH.

MS INT 21H ENDM DATA SEGMENT STR1 DB 20 DB 20 DUP('$) CRLF DB 0AH. DATA.Q:2-(B) Write a program in 8086 assembly language that accept a string from the keyboard and then reverse a string using stack.$ STR2 DB 20 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. 09H LEA DX. STACK_SEG . ES: DATA. DATA MOV DS.0DH. AX MOV AX. AX MOV ES. Ans: PTRSTR MACRO MS MOV AH. The string can be assumed to be available in the data segment. SS: STACK_SEG START MOV AX.

PTRSTR MSG1 MOV AH. 00 MOV DL. 00 LEA SI. 0AH LEA DX.'$' L2: PUSH[SI] CMP[SI]. 4CH INT 21H CODE ENDS END START . BL JE L1 INC SI JMP L2 L1: POP AX MOV[DI]. STR1 INT 21H MOV CX. BL JE L3 JMP L2 L3: PTRSTR CRLF PTRSTR MSG2 PTRSTR STR2+2 MOV AH. AX CMP AL. STR1+1 LEA DI. STR2+2 MOV BL.

AL MOV REMAINDER. AX MOV AX. AH INT 21H MY_CODE ENDS END START . 8 BITDIVISOR ON 2503H QUOTIENT DB? . MY_DATA MOV DS. 16 BIT NUMBER STORED ON 2501H AND 2502 DIVISOR DB 10H . DIVISOR DIV BL MOV QUOTIENT. Ans: MY DATA SEGMENT BLANK_MEMORY_BLOCK DB 2501H DUP(?) DIVIDEND DW 105H. 8 BIT QUOTIENT ON 2504H REMEAINDER DB? MY_DATA ENDS MY_CODE SEGMENT ASSUME CS: MY_CODE. DIVIDENT MOV BL. DS: MY_DATA START: MOV AX.Q:2-© Write a program in 8086 assembly language that devide a 16-bit number stored in memory location 2501 and 2502h with an 8-bit divisor is stored in location 2503h.. Store the quotient in 2504h and remainder in 2505h..

0 JZ L1 MOV AX. X MUL CL ADD AX. X MUL AX MOV BL. AX MOV AL. MY_DATA MOV DS. 4MUL BL ADD AX. AX MOV CL. FLAG CMP AL. X MUL AX MOV BL. 9 ADC AX. BX JMP L2 L1: MOV AX. 7 L2: MOV RESULT. AX INT 21H . 5 MOV AX. Assume x is a 16bit unsigned integer: Ans: MY_DATA SEGMENT X DW 2H FLAG DB 0 RESULT DW? MY_DATA ENDS MY_CODE SEGMENT ASSUME CS: MY_CODE.Q:2-(D) Write a program in 8086 assembly language to evaluate 6*(x^2)+5x+9 If flag==1 or 4*(x^2)+7 if flag==0. 6 MUL BL MOV BX. DS: MY_DATA START: MOV AX.

MY_CODE ENDS END START .