Monday, 19 September 2016

MCA C and Assembly Language Assignment IGNOU Solution 2016



January 2016 Session

IGNOU Assignment Solution


Section1: 
Write an interactive program in C language to create an application program which generates the telephone bills. It stores various details of users Telephone Number, Name, Address, No. of calls, local or STD/ISD call. Compute the amount to be paid if the
charges per local call is Rs. 2/- and for STD/ISD call is Rs. 5/-. It should have feature of searching the customer records using the telephone number. The application should be designed user friendly. Note: You must execute the program and submit the program
logic, sample input and output along with the necessary documentation for this question. Assumptions can be made wherever necessary.

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void calc(int);
struct user{
int telephone;
char name[10];
char address[25];
int local;
int stdisd;
}u[5]={ {1101,"trupti","vadodara",25,0},
{1102,"hitesh","Gotri",75,44},
{1103,"druv","iscon",32,15},
{1104,"alpa","sayajiganj",25,120},
{1105,"sejal","baroda",10,0}, };


void main()
{
int n;
clrscr();
printf("enter telephone number : ");
scanf("%d",&n);
 if(n>1100 && n<1106)
{
 calc(n);
}
else
{
 printf("\nenter valid telephone number ");
}
getch();
}
void calc(int n)
{
struct date D;
float crlocal,crstd,crs,totalc,bill,fix=350;
getdate(&D);
printf("\n\t\t\t\tBSNL BILL\n\n");
crlocal=u[n-1101].local*2;
crstd=u[n-1101].stdisd*5;
totalc=crlocal+crstd;
crs=(fix+totalc)/10;
bill=fix+totalc+crs;
printf("\tNAME : %s\t\t\tBILL DATE:%d/%d/%d ",u[n-1101].name,D.da_day,D.da_mon,D.da_year);
printf("\n\n\tADDRESS : %s\t\tBILL MONTH : %d %d\n",u[n-1101].address,D.da_mon,D.da_year);
printf("\n\t___________________________________________________________________");
printf("\n\n\tNO. OF CALLS\t\t\t\tCHARGES\t\tAMOUNT(RS.)");
printf("\n\t___________________________________________________________________");
printf("\n\n\tLOCAL :\t%d\t\t\tMONTHLY(FIXED) :\t%.0f",u[n-1101].local,fix);
printf("\n\n\tSTD/ISD :\t%d\t\t\tCALL USAGE :\t%.0f",u[n-1101].stdisd,totalc);
printf("\n\n\t\t\t\t\t\tService tax : \t\t%.0f",crs);
printf("\n\t___________________________________________________________________");
printf("\n\n\t\t\t\t\t\tTOTAL AMOUNT\t\t%.0f",bill);
printf("\n\t___________________________________________________________________");
}





Section 2: Assembly Language Programming Lab
1.  (a)  Write a program in assembly language to find the  largest of 3 Numbers.

DATA SEGMENT 
NUM1 DB 1 
NUM2 DB 8 
NUM3 DB 4 
LRGT DB ?
 ENDS 
CODE SEGMENT 
ASSUME 
DS:DATA 
CS:CODE 
START: MOV AX,DATA 
MOV DS,AX 
MOV AL,NUM1 
MOV LRGT,AL 
CMP AL,NUM2 
JGE SKIP1 
MOV AL,NUM2 
MOV LRGT,AL
 SKIP1: MOV AL,LRGT 
CMP AL,NUM3 JGE 
SKIP2 MOV AL,NUM3 
MOV LRGT,AL 
SKIP2: MOV AH,4CH 
INT 21H 
ENDS 
END START 
Output: 8

(b)  Develop and execute an assembly language program to reverse the given number and check if the number is palindrome.

DATA SEGMENT 
NUM1 DW 121 
NUM2 DW ? 
ARRY DB 10 DUP (0) 
TEMP DW ? 
MSG1 DB 10,13,’ NUMBER IS : $’ 
MSG2 DB 10,13,’REVERSE IS : $’ 
MSG3 DB 10,13,’NUMBER IS A PALINDROME $’ 
MSG4 DB 10,13,’NUMBER IS NOT A PALINDROME $’ 
RES DB 10 DUP (‘$’) 
DATA ENDS 

DISPLAY MACRO MSG 
MOV AH,9 
LEA DX,MSG 
INT 21H 
ENDM 

CODE SEGMENT 
ASSUME CS:CODE,DS:DATA 
START: 
MOV AX,DATA 
MOV DS,AX 
DISPLAY MSG1 
MOV AX,NUM1 
LEA SI,RES 
CALL HEX2DEC 
LEA DX,RES 
MOV AH,9 
INT 21H 
LEA SI,ARRY 
MOV AX,NUM1 
REVE: MOV DX,0 
MOV BX,10 DIV BX 
MOV ARRY[SI],DL 
MOV TEMP,AX 
MOV AX,DX 
INC SI 
MOV AX,TEMP 
CMP TEMP,0 
JG REVE 
LEA DI,ARRY
 LAST: INC DI 
CMP ARRY[DI],0 
JG LAST 
DEC DI 
MOV AL,ARRY[DI] 
MOV AH,0 
MOV NUM2,AX 
MOV CX,10 
CONV: 
DEC DI 
MOV AL,ARRY[DI] 
MOV AH,0 
MUL CX 
ADD NUM2,AX 
MOV AX,CX 
MOV BX,10
 MUL BX 
MOV CX,AX 
CMP ARRY[DI],0 
JG CONV 
DISPLAY MSG2 
MOV AX,NUM2 
LEA SI,RES 
CALL HEX2DEC 
LEA DX,RES
 MOV AH,9
 INT 21H 
MOV AX,NUM1 
CMP NUM2,AX 
JE PALIN 
DISPLAY MSG4 
JMP FINISH 
PALIN: 
DISPLAY MSG3 
FINISH: 
MOV AH,4CH 
INT 21H 
CODE ENDS 
HEX2DEC 
PROC NEAR 
MOV CX,0 
MOV BX,10 
LOOP1: 
MOV DX,0 
DIV BX 
ADD DL,30H 
PUSH DX 
INC CX 
CMP AX,9
 JG LOOP1 
ADD AL,30H 
MOV [SI],AL 
LOOP2: 
POP AX 
INC SI 
MOV [SI],AL LOOP LOOP2 
RET HEX2DEC 
ENDP 
Output :
 NUMBER IS : 121 
 REVERSE IS :121 
 NUMBER IS A PALINDROME  


(c)  Write a program in assembly language to find the Square of a given number. 

DATA SEGMENT 
NUM DB ? 
RES DB 10 DUP (‘$’) 
MSG1 DB “ENTER NUMBER : $” 
MSG2 DB 10,13,”SQUARE OF NUMBER IS : $” 
DATA ENDS 
CODE SEGMENT 
ASSUME DS:DATA,CS:CODE 
START: 
MOV AX,DATA 
MOV DS,AX 
LEA DX,MSG1 
MOV AH,9 
INT 21H 
MOV AH,1
 INT 21H 
SUB AL,30H 
MOV NUM,AL
 MOV AH,0 
MUL NUM 
LEA SI,RES 
CALL HEX2DEC 
LEA DX,MSG2 
MOV AH,9 
INT 21H 
LEA DX,RES 
MOV AH,9 
INT 21H 
MOV AH,4CH 
INT 21H 
CODE ENDS 
HEX2DEC 
PROC NEAR 
MOV CX,0 
MOV BX,10 
LOOP1: 
MOV DX,0 
DIV BX 
ADD DL,30H 
PUSH DX 
INC CX 
CMP AX,9 
JG LOOP1 
ADD AL,30H 
MOV [SI],AL 
LOOP2: 
POP AX 
INC SI 
MOV [SI],AL
LOOP LOOP2 
RET HEX2DEC 
ENDP 
END START   

OUTPUT:
ENTER NUMBER : 4 
SQUARE OF NUMBER IS : 16

(d)  Write a program in assembly language find the perimeter of a Rectangle.

DATA SEGMENT 
LEN DB ? BRE DB ? 
RES DB 10 DUP (‘$’) 
MSG1 DB 10,13,”ENTER LENGTH : $” 
MSG2 DB 10,13,”ENTER BREADTH : $”  
MSG3 DB 10,13,”THE PERIMETER IS : $” 
DATA ENDS 

CODE SEGMENT 
ASSUME DS:DATA,CS:CODE 
START:
 MOV AX,DATA 
MOV DS,AX 
LEA DX,MSG1 
MOV AH,9 
INT 21H 
MOV AH,1 
INT 21H 
SUB AL,30H 
MOV AH,0
 MOV BL,2 
MUL BL 
MOV LEN,AL 
LEA DX,MSG2 
MOV AH,9 
INT 21H 
MOV AH,1 
INT 21H 
SUB AL,30H 
MOV AH,0 
MOV BL,2 
MUL BL 
MOV BRE,AL 
ADD AL,LEN 
LEA SI,RES
 CALL HEX2DEC 
LEA DX,MSG3 
MOV AH,9 INT 21H 
LEA DX,RES 
MOV AH,9 INT 21H 
MOV AH,4CH 
INT 21H 
CODE ENDS 
HEX2DEC 
PROC NEAR
 MOV CX,0 
MOV BX,10 
LOOP1: 
MOV DX,0 
DIV BX 
ADD DL,30H 
PUSH DX 
INC CX 
CMP AX,9 
JG LOOP1 
ADD AL,30H 
MOV [SI],AL 
LOOP2: POP AX 
INC SI 
MOV [SI],AL 
LOOP LOOP2 
RET HEX2DEC 
ENDP 
END START

OUTPUT
ENTER LENGTH : 5
ENTER BREADTH : 7  
THE PERIMETER IS : 24


Thank you,
Hitesh Vataliya.


FOR MORE INFORMATION :
Visit Our Center : 
120-121, Gangotri Complex,
30 Meter Gotri Road,
Near Yash Complex,
Gotri, Vadodara - 390021
Gujarat, India.
Contact No: +91 9726185104

No comments:

Post a Comment