Wednesday, September 17, 2008

MCA SOLVED ASSIGNMENT MCS 07 (PROJECT)

MCS 07 (PROJECT)


Q. 1. Write an interactive C language to manage the study centre with menu options like student’s details, semester enrolled for, assignments submitted and marks obtained, attendance for the practical courses etc. Using the file handling concepts. The application should he 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.

Ans. C Program:

/* Include files
********************************/
#include //-------Header file for printf, scanf
#include //-------Header file for getch(), clrscr()
#include //--------Header file exit function

/************************************************
17user defined structure
************************************************/
///-----------structure used to define date data type

Struct date
{
Int dd;
Int mm;
Int yy;
};

//--------- structure to store personal details
Struct personal
{
Char fname[20];
Char mname[20];
Char lname[20];
Char address [50];
};

//------- structure to store student’s enrollment.


//----------Assumption : One student can enroll at max. One program.

Struct enrollment
{
Char program [30]; //--------program like, B.Sc , B. Tech(IT),
B. Tech. (CE)
Etc……
Int sem; //-----semester
Struct date doe;

};

//-----structure to define subject detail like name of subject, assignment submitted or not, marks
// obtained
//-----Assumption-one . student can have at max 5 courses
struct subjects
{
Char sub_nm[30];
Char ass_flag //---assigment submitton flag, ‘y’ or ‘n’
Int marks;
};

//----- student structure
Struct student
{
Int rollno;
Struct personal pers_dtl;
Struct enrollment enr_dtl;
Int subj_cnt;
Struct subjects sub_dtls[5];
};
Typedef struct student student;

/****************************************************************
Function prototypes
****************************************************************/

Void printLine(int count, char ch);
Void printHeader ();
Char printMenu();
Void continue_prog();
Void add_student (FILE *fp);
Void view_student (FILE *fp, char choice);
Void update_student (FILE *fp, char choice);

/*************************Main Program********************************/
Void main ()
//---------declaration section
Char ch, filename[20];
FILE *fp;

//--------------------file open
Fp= fopen (“z:\’\ student. Dat “,”w+”);

While (1)
{
Ch= printMenu();
Switch (ch)
{
Case ‘1’ :
Add_student(fp);
Break;
Case ‘b’ :
View_student(fp,’b’);
Break;
Case ‘c’ :
View_student(fp,’c’);
Break;
Case ‘d’ :
View_student(fp,’c’);
Break;
Case ‘A’ :
Update_student(fp,’A’);
Break;
Case ‘B’ :
Update_student(fp,’B’);
Break;
Case ‘C’ :
Update_student(fp,’C’);
Break;
Case ‘D’ :
Update_student(fp,’D’);
Break;
Case ‘4’ :
Update_student(“\n THANK YOU ………..”);
Break;
Exit(0);
}
}//----enf of while
Fclose (fp)
//--- terminate program
Printf(“\n press any key to continue ……………………….”);
Getch();

/***************************************************************
18procedure : srch_std
19purpose : search student in a file
20input :
o 1. rollno: int
o 2. fp : FILE
*Output :
Offset, if record found
-1, if not found
****************************************************************/
Int srch_std(int rolledno, FILE *fp)
{
Int num;
//------declaration section
Int pos=-1;
Student s1;
//-- search record
Fseek(fp,0,0); //--set file pointer to begin of file
While (!feof(fp))
{
Num=fsacnf(fp, “%d”, &s1.rollno);
If(num==rollno)
Pos = ftell(fp)-sizeof(s1);
}
} //--- end of while
Return pos;
}

/******************************************************************
* procedure : update_student
* purpose : Read a roll number, and display student’s details for given roll number
* Input
* 1. fp : FILE *//--pointer to a file which contain data
* 2. choice : char //--- choice for which detail is required to be viewed
*output : None
******************************************************************/
Void update_student(FILE *fp, char choice)
{
//---declaration section
Student s1;
Int rno;
Int cno;
Int pos,
Int I;
//--- Enter rollno to be viewed
Printf(“\n Enter Roll number to be viewed :”);
Scanf(“%d”, &rno);

//---- Search student record with entered rollno from a file
Pos =srch_std;
//---if record not found
If(pos== -1)
{
Printf(“\n No record found for %d rollno”, rno);
Return;
}
//---If record found
Ftell(fp);
printHeder();
fscanf(fp, “%d”, &s1. rollno);
printf (“\nStudent Rollno : %d”,s1:rollno);
switch(choice)
{
Case ‘A’ ://--- personal detil
Printf(“\n*******************personal details************);
Printf(“\nEnter firstname middlename LastName : “);
Scanf(“%s %s %s”, &s1.pers_dt1.fname, &s1.pers_dt1.mname,&s1.pers_dt1.lname);
Fprintf (“%s %s %s”, &s1.pers_dt1.fname, &s1.pers_dt1.mname,&s1.pers_dt1.lname);
Printf (“\n Enter Address : ”);

scanf("%s", &s1.pers_dt1.address);
fprintf(fp, "%s", &s1.pers_dt1.address);
printf("\nEnter Date of birth (dd-mm-yy) : ");
scanf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.dob.yy);
fprintf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.dob.yy);


printf("\n*********************************************);
break;

case 'B': //......enrollment detail
printf("\n\n***********Enrollment Detail*****************);
printf("\nEnter program Name :");
scanf("%s",&s1.enr1_dt1.program);
fprintf(fp, "%s",&s1.enr1_dt1.program);

printf("\nEnter semester :");
scanf("%s",&s1.enr1_dt1.sem);
fprintf(fp, "%s",&s1.enr1_dt1.sem);
printf("\nEnter Date of enrollment (dd-mm-yy) : ");
scanf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.dob.yy);
fprintf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.dob.yy);
printf("\n*********************************************);
break;

case 'C': //--- assignment details
printf(************Assignment Detiail******************);
for( i=0; i {
printf ("\nsubject %s :" ,s1.sub_dtls[i].sub_nm);
printf ("submitted ?(y/n) ;");
scanf("%c", &s1.sub_dtls[i].ass_flag);
fprintf(fp, "%c", &s1.sub_dtls[i].ass_flag);
scanf("%c ", &s1.sub_dtls[i].ass_flag[i].ass_flag);
fprintf(fp, "%c ", &s1.sub_dtls[i].ass_flag[i].ass_flag);
}
break;

case 'D': //--- marks details
printf(************Marks Detiail******************);
for( i=0; i {
printf ("\nEnter Mark For subject %s :" ,s1.sub_dtls[i].sub_nm);
scanf("%c", &s1.sub_dtls[i].marks);
fprintf(fp, "%c", &s1.sub_dtls[i].marks);
}
break;
}
//----update record in file
ftell (fp);
//fwrite (&s1, sizeof (s1),1,fp);

continue_prog();
/***************************************************
*procedure : view_student
*purpose Read a roll number, and dislay student's details for given roll number
* input
*1. fp : File * // ***** pointer to a file which contain data
* 2. choice : char. //---choice for which detail is requried to be viewed
* output : None
**************************************************/
void view_student(FILE * fb, char choice)
{
//----declaration section
student s1;
int rno;
int pos;
int i;
int count;
//--- Enter rollno to be viewed
printf("\nEnter Roll Number to be Viewed :");
scanf("%d", &rno);

//--- Search student record with entered rollno from a file pos=srch_std;

//--- if record not found
if(pos== -1)
{
printf("\n No record found for %d rollno", rno);
return;
}

//--- if record found
ftell (fp);
//fread(&s1,sizeof(s1),1,fp);
printHeader();
fseek(fp,oL,0);
fscanf(fp," %d", &s.rollno);
printf("\nRoll no %d :" , s1.rollno);
swithch(choice)
{
Case ‘A’ ://--- personal detail
Printf(“\n*******************personal details************);
Printf(“\nEnter Firstname Middlename LastName : “);
Scanf(“%s %s %s”, &s1.pers_dt1.fname, &s1.pers_dt1.mname,&s1.pers_dt1.lname);
Fprintf (“%s %s %s”, &s1.pers_dt1.fname, &s1.pers_dt1.mname,&s1.pers_dt1.lname);
Printf (“\n Enter Address : ”);
scanf("%s", &s1.pers_dt1.address);
fprintf(fp, "%s", &s1.pers_dt1.address);
printf("\nEnter Date of birth (dd-mm-yy) : ");
scanf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.dob.yy);
fprintf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.dob.yy);


printf("\n*********************************************);
break;

case 'B': //......enrollment detail
printf("\n\n***********Enrollment Detail*****************);
printf("\nEnter program Name :");
scanf("%s",&s1.enr1_dt1.program);
fprintf(fp, "%s",&s1.enr1_dt1.program);

printf("\nEnter semester :");
scanf("%s",&s1.enr1_dt1.sem);
fprintf(fp, "%s",&s1.enr1_dt1.sem);
printf("\nEnter Date of enrollment (dd-mm-yy) : ");
scanf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.doe.yy);
fprintf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.doe.yy);
printf("\n*********************************************);
break;

case 'C': //--- assignment details
printf(************Assignment Detiail******************);
for( i=0; i {
printf ("\nsubject %s :" ,s1.sub_dtls[i].sub_nm);
printf ("submitted ?(y/n) ;");
scanf("%c", &s1.sub_dtls[i].ass_flag);
fprintf(fp, "%c", &s1.sub_dtls[i].ass_flag);
scanf("%c ", &s1.sub_dtls[i].ass_flag[i].ass_flag);
fprintf(fp, "%c ", &s1.sub_dtls[i].ass_flag[i].ass_flag);

}
break;

case 'D': //--- marks details
printf(************Marks Detiail******************);
for( i=0; i {
printf ("\nEnter Mark For subject %s :" ,s1.sub_dtls[i].sub_nm);
scanf("%c", &s1.sub_dtls[i].marks);
fprintf(fp, "%c", &s1.sub_dtls[i].marks);
}
break;
}

continue_prog();

/***************************************************************
* procedure : continue_prog
*purpose : print a message. Halt for trigger and switch to menu.
*Input : None
* Output : None
***********************************************************/

void continue_prog()
{
printf("\n\t\tpress any key to continue........");
getch();
}

/*************************************************************
* percedure : add_student(fp)
* purpose : Add new student record in file
* Input : fp : FILE"
* Output : None
***********************************************************/

void add_student(FILE *fp)
{
//---- declaraton section
student s1;
int i;
//-- read of input data
ptintHeader();

printf("\nEnter Student Roll number :");
scanf("%d", &s1.rollno);
fprintf(fp," %d",s1.rollno);
//---- check , does this student exist
if(srch_std(s1.rollno, fp) != -1)
{
printf("\nSorry, this rollno already exist");
continue_prog();
}
//----Enter Personal Detail
Printf(“\n*******************personal details************);
Printf(“\nEnter Firstname Middlename LastName : “);
Scanf(“%s %s %s”, &s1.pers_dt1.fname, &s1.pers_dt1.mname,&s1.pers_dt1.lname);
Fprintf (“%s %s %s”, &s1.pers_dt1.fname, &s1.pers_dt1.mname,&s1.pers_dt1.lname);
Printf (“\n Enter Address : ”);
scanf("%s", &s1.pers_dt1.address);
fprintf(fp, "%s", &s1.pers_dt1.address);
printf("\nEnter Date of birth (dd-mm-yy) : ");
scanf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.dob.yy);
fprintf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.dob.yy);


printf("\n*********************************************);

//......enrollment detail
printf("\n\n***********Enrollment Detail*****************);
printf("\nEnter program Name :");
scanf("%s",&s1.enr1_dt1.program);
fprintf(fp, "%s",&s1.enr1_dt1.program);

printf("\nEnter semester :");
scanf("%s",&s1.enr1_dt1.sem);
fprintf(fp, "%s",&s1.enr1_dt1.sem);
printf("\nEnter Date of enrollment (dd-mm-yy) : ");
scanf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.doe.yy);
fprintf("%d, %d, %d ", &s1.pers_dt1.dob.dd, &s1.pers_dt1.dob.mm, &s1.pers_dt1.doe.yy);
printf("\n*********************************************);

printf("\n\n***********Subjecct details****************************);
printf("\n How many subject enrolled :");
scanf ("%d",&s1.subj_cnt);
fprintf(fp," %d",s1.subj_cnt);
for( i=0; i {
printf("\nSubject Name :");
scanf("%s",&s1.sub_dtls[i].sub_nm);
fprintf(fp," %s", s1.sub_dtls[i].sub_nm);
s1.sub_dtls[i].ass_flag='n';
s1.sub_dtls[i].marks=0;
}

//--- assignment details
printf(************Assignment Detiail******************);
for( i=0; i {
printf ("\nsubject %s :" ,s1.sub_dtls[i].sub_nm);
printf ("submitted ?(y/n) ;");
scanf("\n%c", &s1.sub_dtls[i].ass_flag);
fprintf(fp, "%c", &s1.sub_dtls[i].ass_flag);
scanf("%c ", &s1.sub_dtls[i].ass_flag[i].ass_flag);
fprintf(fp, "%c ", &s1.sub_dtls[i].ass_flag[i].ass_flag);

}
//--- marks details
printf(************Marks Detiail******************);
for( i=0; i {
printf ("\nEnter Mark For subject %s :" ,s1.sub_dtls[i].sub_nm);
scanf("%c", &s1.sub_dtls[i].marks);
fprintf(fp, "%c", &s1.sub_dtls[i].marks);
}

//----insert student's record in file
fseek (fp, -1, SEEK_END));
//fwrite (&s1, sizeof (s1),1,fp);

continue_prog();
}

/*******************************************************************************
* prpcedure : printLine
*purpose : print a line with repeatation of chararctaer symbol
*Input :
** 1.count: int => specifies number of times a character to be printed
* 2.ch :- char=>specifies symbol to be printed
* Output : None
********************************************************************/
void printLine(int count, char ch)
{
int i;
printf("\n");
for(i=0; i {
printf("%c",ch);
}
}
/**********************************************************
*procedure : printHeader
*purpose : print page header
* Input : None
*Output : None
***********************************************************/

void printHeader()
{
clrscr();
printLine (80,'*');
printLine (80,'*');
printLine (20,'*');
printLine("STUDENT MAANGEMENT SYSTEM");
printLine(80,'*');
printLine(80,'*');
}

/*****************************************************************
* Procedure : printMenu
* Purpose : print Header, and Menu. Read choice from user input
and
return
* Input : None
*output :
* 1. ch : char=> specifies choice ('1' or '2' or '3' )
****************************************************************/
char printMenu()
{
char ch; //******* ****************Main Menu*************************
main_menu;
while(ch<'1'|| ch>'4'
{
printHeader();
printf("\n1'. Add A Student Record : ");
printf("\n2'. Add A Student Record : ");
printf("\n3'. Add A Student Record : ");
printf("\n4'. Exit : ");
printLine(40, "-");
printf("\n Enter your choice : ");
flushall();
scanf("%c",&ch);

printLine(40, '-' );
if(ch< '1' || ch>'4')
{
printf("\n Enter Valid choice. Please try again. ")
printf("\n Press any key to continue");
getch();
}
printLine(80, '*');

if(ch=='1' || ch== '4') //---- if ch is '1', return for
add_student, process '4' for exit.

return ch;
else if (ch=='2') //------ display view menu.
{
while(ch<'a' || > 'e')
{
PrintHeader();
printf(" \na. view Personal Detail " );
printf(" \nb. view Emrollment Detail " );
printf(" \nc. view Assignment Detail " );
printf(" \nd. view Marks " );
printf(" \ne. Back previous menu ");
scanf("%c",&ch);

if(ch<'a' ||>'e')
{
printLine(40, '_');
printf(" \n Enter Valid Choice Please try again . " );
printf("\n Press any key to continue.. " );
printLine(80, '*');
}
}
if (ch= ='e')
goto main_menu;
else
return ch;
}
else if (ch==3) //----- display update menu
{
while(ch< 'A' || ch> 'E')
{
PrintHeader();
printf(" \nA. view Personal Detail " );
printf(" \nB. view Emrollment Detail " );
printf(" \nC. view Assignment Detail " );
printf(" \nD. view Marks " );
printf(" \nE. Back previous menu ");
scanf("%c",&ch);

if(ch<'a' ||>'E')
{
printLine(40, '_');
printf(" \n Enter Valid Choice Please try again . " );
printf("\n Press any key to continue.. " );
printLine(80, '*');
}
}
if (ch= ='E')
goto main_menu;
else
return ch;
} //----end of update menu
}
}



































Q2. Write an assembly language program to accept a decimal number and display its hexadecimal equivalent.
Ans:
; decibin - get decimal digits from keyboard
; and convert them to binary in BX regoster

. model tiny
.code
.startup
;-------------------------------

; main program loop

start :

call read_num
call print_crlf
call print_hex
call print_crlf
jmp start ; loop endlessly

; *****************************************************************
; print_crlf
; prints out a carriage return and linefeed
; *****************************************************************

print_crlf proc
mov ah, 2h ; print character function
mov dl, 0dh ; carriage return
int 2lh ; print it
mov dl, 0ah ; linefeed
int 21h ; print it

ret
print_crlf endp

; ***************************************************************************
; read_num
; reads a number from keyboard input
; and stores it in BX in binary
; ***************************************************************************

read_nem proc

mov bx, 0h ; clear bx for number
;
; get digit form keybard and
; conevrt it to binary
;
newchar :
mov ah 1h ; keyboard input function
int 21h ; execute ^ with dos
sub a1, 30h ; ascii to binary
j1 endinpt ; jump if < 0
cmp a1, 9d ; is it > 9d?
jg endinpt ; yes, not decimal digit
cbw ; byte in a1 to wrod in ax

; digit is new in AX
; multiply number in Bx 10d

xchg ax, bx ; trade digit and number
mov cx, 10d ; put 10d in CX
mul cx ; number times 10d
xchg ax, bx ; trade number and digit
;
; add digit in AX to number in BX
;
add bx, ax ; add digit to number
jmp newchar ; get next digit
;
; check to see wht they entered
; if nothing, exit
; otherwise, return from process
;
endinpt :
emp bx, 0h ; is it 0?
jne return ; nope, return from process
exit ; yup, exit program
return :

ret
read_num endp

; **************************************************************
; print_hex
; print in hex to the sereen the contents of
; BX
; *************************************************************
print_hex proc

mov ch, 4h ; number fo digits to print

; start with first digit in Bx
; register

rotate:
mov c1, 4h ; set count to 4 bits
rol bx, cl ; left digit to right

; convert to number
mov a1, b1 ; mov to AL
and a1, 0fh ; mask off digit
add a1, 30h ; convert hex to ascii
cmp a1, 3ah ; is it > 9?
jl printit ; jump if digit =0 to 9
add a1, 27h ; digit is A to F

; print the digit in
; the AL register

printit :
mov dl, al ; put ASCII char inDL
mov ah, 2h ; display output function
int 21h ; call DOS
dec ch ; done 4 digit =0 to 9
jnz rotate ; not yet

; fallthrough and return
ret
print_hex endp
end











Q.3 Write a program to evaluates 4*(4^2)+3x +7 if flag = = or evaluates 9x+3 if flag = = 0. Assume x is a 16-bit unsigned number.

Ans.
.model small
.data
prompt1 db = " enter the number for flag "
prompt2 db = " enter the number X "
prompt3 db = " the result is "
X db ?
num db ?

.code
disp prompt1
call read_num
print _crlf ; read the number for flag
mov ax,num
add ax, num
jnc f0
disp prompt2
set ; check if carry flag
call read_num
print_crlf

mov ax,x
f1:
mul ax
mul 4
mov dx, ax
mul 3
add ax,dx
add ax, 07
jmp exit
f0 : mul 09
add ax,03
jmp exit

disp prompt3

; *********************************************************************************
; print_crif
; print out a carriage return and linefeed
; ********************************************************************************

print_crlf proc
mov ah, 2h ; print character function
mov dl, 0dh ; carriage return
int 21h ; print it
dl, 0ah ; linefeed
int 21h ; print it
ret
print_crlf endp

; ********************************************************************************
; reads number from keyboard
; ********************************************************************************

read_num proc
mov bx, oh ; clear bx for number
int 21h ; execute ^ with dos
sub a1, 30h ; ascii to binary
j1 endinpt ; jump if < 0
cmp a1, 9d ; is it > 9d?
jg endinpt ; yes, not decimal digit
cbw ; byre in a1 to word in ax

; digit is now in AX
; multiply number in BX by 10d

xchg ax, bx ; trade digit and number
mov cx, 10d ' put 10d in CX
mul cx ; number times 10d
xchg ax, bx ; trade number and digit

;
; add digit in AX to number in BX
;

add bx, ax ; add digit to number
jup newchar ; get next digit

; check to see what they entered
; if nothing, exit
; otherwise, return form process

endinpt :
cmp bx, 0h ; is it 0?
jne return ; return from process
exit
return :
ret
read_num endp
disp macro msg
mov ah, 09h
lea dx, msg
int 21h
disp endm

Exit : mov ax, 4c00h
int 21h

; ***************************************************************************
; OUTPUT
; ***************************************************************************

enter the number for flag 5
enter the number X 2
the result is 21






















Q.4 Write a program, which reads two decimal numbers, multiply them and display the product in decimal.

Ans.
.model small
.Data
Prompt1 db “Enter first number”
Prompt2 db “Enter second number”
Prompt3 db “The result is ”
.code
Disp macro msg
Mov ah, 09h
Int 21h
: disp endm
Call read_num
Mov ax, x
Cmp flag, 00
Je f0
F1: mul ax
Mul 3
Add ax, dx
Add ax, 07
Jmp exit
F0 mul 09
Add ax, 03

Disp prompt1
Call read_num
Mov bx, ax
Print clf
Disp prompt2
Call read_num
Mul bx
Print clf
Disp prompt3
Call write_num

Exit: mov ax, 4c00h
Int 21h

;**************************************************************************************
Read the decimal number
;**************************************************************************************

Read_num proc
Mov bx, 0h ; clear bx for number
; get digit form keyboard and
Newchar:
Mov ah 1h ; keyboard input function
Int 21h ; execute ^ with dos
Sub a1, 30h ; ascii to binary
J1 endinpt ; jump if < 0
Cmp a1, 9d ; is it > 9d?
Jg endinpt ; yes, not decimal digit
Cbw ; byre in a1 to word in ax


; digit is now in AX
; multiply number in BX by 10d

Xchg ax, bx ; trade digit and number
Mov cx, 10d ; put 10d in CX
Mul cx ; number times 10d
Xchg ax, bx ; trade number and digit

; add digit in AX to number in BX

Add bx, ax ; add digit to number
Jmp newchar ; get next digit

; check to see what they entered
; if nothing, exit
; otherwise, return from process
Endinpt:
Cmp bx, 0h ; is it 0?
Jne return ; return from process
Exit ; exit program

Return: ret
Read_num. endp

;************************************************************************************
; display the decimal number
;************************************************************************************

Write_num proc
Push dx ; save the values of all
Registers
Push cx
Push bx
Push ax

Mov cx, 0
Lea di, buffer_B+6
Mov bx, 10
B2: mov dx, 0
Div bx
Or d1, 30h ; separate each digit
Dec di
Mov [di ], d1 ; form the array of digits
Inc cx
Or ax, ax
Jnz b2

B3: mov ah, 2 ; display each digit
Mov d1, [di]
Int 21h
Inc di
Loop b3 ; continue till all digits displayed

Pop dx
Pop cx
Pop bx
Pop ax

Return: ret
Write_num endp

;******************************************************************************************; print_crlf
; prints out a carriage return and linefeed
;******************************************************************************************

Print_crlf proc

Mov ah, 2h ; print character function
Mov d1, 0dh ; carriage return
Int 21h ; print it
Mov d1, 0ah ; linefeed
Int 21h ; print it

Ret
Print_crlf end
End

;******************************************************************************************
OUTPUT
;******************************************************************************************

Enter first number: 8
Enter second number: 6
The result is: 48








































Q.5 Write an assembly language program to implement a stack

Ans.
----------------------------------------------------------------------------------------------------------------
; use of stack to print reverse of string
----------------------------------------------------------------------------------------------------------------

.model tiny
.stack 100h
.code
Mov cx, 0
Read_char: mov ah, 1 ; read character typed by programmer
Int 21h
Cmp a1, 0dh ; if enter key pressed go to endof
Line
Je end_of_line

Push ax ; push character in stack
Inc cx ; increment count_of_char
Jmp read_char ; go to read_char

End_of_line : pop dx ; pop character form stack
Mov ah,2 ; display poped character
Int 21h
Loop end_of_line ; if count_of_char>0 goto
End_of_line
Int 20h

;------------------------------------------------------------------------------------------------------------------------------
; OUTPUT
;----------------------------------------------------------------------------------------------------------------------------
dbcd
dcba


Website counter






Tuesday, September 16, 2008

MCA SOLVED ASSIGNMENTS MCS 015

MCS 015
Communication Skills



Q1. Read the following passage carefully.

Psychoanalysts treat their patients by delving into their past – often their early years of childhood – in an attempt to help them understand present feelings and behavior. Consultants try to understand their clients’ history and track record in an attempt to identify the roots of failure or the seeds of success.
In some respects, consultants have an easier job; they can look over past balance sheets and profit and loss statements in order to analyze the management of assets, profitability and cost control. They can follow the company’s history through from its initial successes with perhaps a single product to its present-day range of products or services. They can study the organizational structure of the company, marketing and personnel policies, even the physical layout of offices and factory.
However, putting their finger on why one company fails and another succeeds is not always so easy. Companies look outside for this advice because they cannot find the answers themselves. They hope that the consultant will be able to draw on his or her wider experience – perhaps recognize a symptom that he has previously encountered. Then perhaps he or she will be able to diagnose their ills, prescribe a course of treatment for recovery and recommend a new life-style to ensure future health and prosperity.
Now answer the following questions:

i. Why do Psychoanalysts and consultants need to delve into the past of their patients and clients?
Answer:
Psychoanalysts and consultants need to delve into the past of their patients and clients so that they could know the reasons for their failure or success.

ii. Why do you think a consultant’s job is easier than a Psychoanalyst?
Answer:
A consultant’s job is easier than a Psychoanalyst because they can look into companies balance sheets and profit and loss statements in order to analyse the management of assets, profitability and cost control.

iii. Companies evidently want help from consultants from time to time. Why? Discuss.

Answer:
Companies want help from consultants from time to time because companies cannot find the answers themselves. They hope that consultant will be able to diagnose their ills and prescribe treatment for recovery.

Iv. Taking the passage as the basis, write in about 100 words. “The role of a consultant in a company”.

Consultants try to understand their clients’ history and track record in an attempt to identify the roots of failure or the seeds of success. consultants have an easier job. they can look over past balance sheets and profit and loss statements in order to analyse the management of assets, profitability and cost control. They can follow the company’s history through from its initial successes with perhaps a single product to its present-day range of products or services. They can study the organizational structure of the company, marketing and personnel policies, even the physical layout of offices and factory.

v. Give an appropriate title to the passage.

Answer:
“Lead Consultants“ is the title for the passage.
Q2(a). Match the following words from the text in column A with their meanings in column B:
Answer.

Word Meaning
i To delve a Dig, try to uncover
ii Track record b History of achievements
iii Roots c Origins, beginnings
iv Seeds d Origins, causes
v Layout e Configuration
vi To put your finger on f Use, refer to
vii To restore g Bring back to original form
viii Encounter h Come across

Q2(b). As we saw in the passage, it is possible to draw parallels between business and human health. Match the common medical terms with their business equivalents.
Answer.

Medical Term Business term
i Symptom a Sign/indicator
ii Diagnose b Identify/conclude
iii Medical history c Track record
iv Course of treatment d Policy/strategy
v Recovery e Turn-around

Q5. Fill in the blanks with the correct form of the verbs in brackets:
Answer.
i) The consultant had never worked in London before she got this contract.
ii) She recently decided to move to London.
iii) She was driving to London when the storm began.
iv) While the manager was talking to the consultant, the employees packed the prints ready for dispatch.
v) Is that what those men were working on when I came in?
vi) Unless we invest in our staff, they will not stay with the company.
vii) After the initial launch, we plan to extend it to the rest of the country.
viii) We would be doing much better if we had not wasted so much money last year.
Q6. Complete the following phrasal verb in the sentences by inserting an appropriate adverb.
Answer.
i) I can’t get to Munich this week, so I’m going to put off my visit till next week.
ii) Despite our efforts, the negotiations have broken down again.
iii) I’m very relieved that the workers have called the strike off.
iv) Before you leave, make sure that you shut down the computer system.
v) I look forward to seeing you in the near future.
vi) To get through security, you’ll have to fill up a form.
vii) I’m afraid I didn’t understand that point. Could we come up to it afterwards?
viii) We’ve decided to increase our offer; we’ve put it up by $ 30,000.
ix) Let’s throw this idea away and see if it has any potential.
x) He ran into an enormous telephone bill.
Q8. Mark the stress in the following words:
i. Delve
ii. Psychoanalysts
iii. Consultant
iv. Assess
v. Organization
vi. Identify
vii. Profitability
viii. Recommend
ix. Experience
x. Personnel







We complete remaining solutions soon……………..so keep watching www.spynethub.com






Website counter

MCA SOLVED ASSIGNMENTS OF MCS 014

`question 2: prepare data flow diagram to the required level for the above said problem mentioned a problem to cover the process?
Answer: the component of a design method is data flow diagram :
Data flow diagram : have been used for many years prior to the
Advent of computer .DFD show the flow of data through a system .the system may be a company ,an organization a set of procedure a computer hardware system a software system or any combination of the proceeding the DFD also known as data fl ow graph or a bubble chart also. the following information about DFD are important
1) All name should be unique this makes it easier to refer to items of the DFD.
2) Remember that the DFD is now a flow chart .arrows in a flow chart representation the order of events ;arrow in DFD represent following data .a DFD does not imply any order events ./
3) Suppress logical decision if we ever have the urge a diamond shaped box is used in flow chart to represent decision point with multiple exit path of which only one is taken this implies as odering of events which makes no sense in DFD
4) Do not become bogeed down in a details
5) Defer ereo condition and eror handling until the end of the analysis .


bh











Question :3 prepare an entity relationship diagram for the billing application of a petrol retail outler consider all the related entity attributes and relationships .
Answer :


























Question:4
with the help pf an example for each, discuss the significance and the Gantt chart, pert chart and HIPO chart.
Answer:
PERT chart- Prior to the development of PERT the most popular technique for project scheduling. This chart show a graphical representation of work on a time scale.pert is concern with probability there is a expected of critical path in this method the project duration has associated probability



Gantt Chart- it is a project control technique that can be used for several purposes, including scheduling, budgeting and resources planning. It is used almost exclusively for scheduling purposes, and therefore controls only the time dimension of projects.



HIPO- It is a tool commonly used for developing system software. (Hierarchy plus Input- Process-Output) Pronounced”hy-po.” An IBM flow- charting technique that provides a graphical method for designing and documenting program .
This method was originally developed to provide documentation assistance for programmers/analysts.







Website counter

MCA SOLVE ASSIGNMENTS MCS - 012

Question 1(a) use and bit binary representation for integer using signed 2’s compliment notation. Use this representation to performing the following operations on decimal numbers.
1. add -52 and 60
Solution.
00110100 (52)
00111100 (60)

11001100 (-52)
00111100 (60)
100001000

1 is discarded

2. subtract 20-100

00010100 (20)
01100100 (100)
01111000 (120)

(b) Convert the hexadecimal number F5B6D3 to binary and octal.
Solution.
(15, 5, 11, 6, 13, 3)
(001111 00101, 01011, 00110, 01101, 00011)

d) Draw a logical diagram of a 2×4 line decoder with only NOR gate. Include an enable input E so that the circuit is enabled when E-1 and disabled when E=0. Also list the truth table.

n=Input
2n=Output
Single enable line

I0 O0
O1
O2
I1 O3



E


N=2
2n = 22 = 4











TRUTH TABLE



input output
I0 I0 O0 O1 O2 O3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1



f) Representation the number (55.5)10 on a floating- point binary number with 24 bits. The normalized fraction mantissa has 16 bits and the exponent has 8 bits.
Solution. Here mantissa has = 16 bits
Exponent =8 bits
Now floating point ALU.

















(5.5)10

Here base=10
Floating point no.
3.5
It’s a higher positive no:-

5 * (0.5)10

5 + (0.5)10 * 2 -128

5 + 0.5 * 2-128
Mantissa representation







Question.2 Design a counter with the following represented binary sequence.
0, 1, 1, 2, 3, 4, 5, 6, 7, 8 using JK flip-flop.
J and K Flip-flop

Counters in flip-flop:- a counter is register whose values are incremented by 1 on the occurrence of some event. When the value is stored in counter reaches the man value it can store the next incremented value becomes 0(zero).The counter are used for counting the no of times of on event occurs and are useful for generating the timing. Signals for controlling the sequence of operation in digital computers.

Diagram for Flip-flop





(c)Pipelining:- It is a technique of decomposing a sequential process into sub operations, with each sub process being executed in a special dedicated segment that operates concurrently with all other segments. A pipelining can visualize as a collection of processing segment through which binary information flows.


Latency time: - time taken by a head to search a track and. It is read all data from any track.

Raid:-Raid is method which is use for mapping the data and mirroring the data.

Example:-






Mirroring of data

VON NEUMEN COMPUTER


















d) Difference between CD – ROM and DVD ROM

CD – ROM
CD- compact disk ROM is uses for reading
the data of CD and it is a hardware device. DVD – ROM
DVD- ROM uses for reading DVD’s data and it is also a DVD device. It is beneficial for reading the data from DVD.

Question3.

Right shift:-
11100011
After right shifting




1 1 1 0 0 0 1 1




1 1 1 1 0 0 0 1

After left shift:-
1 0 0 1 1 1 0 0



Question3 (b) simplify the following Boolean function in sum of products forms by a four variable K-map. Draw the logical with (a) OR-NAND gate (b) NOR gate.
F(a,b,c,d)= €( 1,3,5,6,7,9,11,14,15)


AB/CD C¯D¯ C¯D CD CD¯
A¯B¯ 0 1 3 2
A¯B 4 5 7 6
AB 12 13 15 14
AB¯ 8 9 11 10


F= A¯B¯D + A¯C¯D + ABC + BCD¯ + ACD

A B C D























Question 4(c) semiconductor memory: - the first memory chip was constructed in 1970 and could held 256 bits that means 28 .
Microprocessor: - Firstly is developed in 1971. In 1993, Intel annoc Pentium with 64 bits microprocessor.







Website counter

MCA SOLVED ASSIGNMENTS

MCS 011
Problem Solving and Programming


Q1: The factorial of non-negative integer n is written n! and is defined as follows:
n! = n * (n – 1) * (n – 2) . …. .1 (for values of n greater than or equal to 1).
and
n! = 1 (for n =0).
Perform the following:
1. Write a C program that reads a non-negative integer and computes and prints its factorial.


#include

main()
{
int n,i,fact=1;
clrscr();
start:
printf("Enter n value: ");
scanf("%d",&n);
if(n<0)
{
printf("Please enter non-negetive value\n");
goto start;
}
for(i = 1;i<=n;i++)
{
fact = fact*i;
}
printf("Factorial of %d is %d\n",n,fact);
getch();
}





2. Write a C program that estimates the value of the mathematical constant e by using the formula: e = 1 + 1/1! + 1/2! + 1/3! + …..


#include
main()
{
int n,i,f=1,j;
float e = 1.0;
clrscr();
start:
printf("Enter n value: ");
scanf("%d",&n);
if(n<0)
{
printf("Please enter non-negetive value\n");
goto start;
}
for(i = 1;i<=n;i++)
{
for(j = 1;j<=i;j++)
{
f = f*j;
}
e=e+((float)1/f);
f=1;
}
printf("Result is: %f\n",(float)e);
getch();
}






3. Write a C program that computes the value ex by using the formula
ex= 1 + x/1! + x2/2! + x3/3! + …..


#include
#include

main()
{
int n,i,f=1,j,x;
float e = 1.0;
clrscr();
start:
printf("Enter n value: ");
scanf("%d",&n);
printf("Enter x value: ");
scanf("%d",&x);
if(n<0)
{
printf("Please enter non-negetive n value\n");
goto start;
}
if(x<0)
{
printf("Please enter non-negetive x value\n");
goto start;
}
for(i = 1;i<=n;i++)
{
for(j = 1;j<=i;j++)
{
f = f*j;
}
e = e+((float)pow(x,i)/f);
f = 1;
}
printf("Result e^x = %f\n",(float)pow(e,x));
getche();
}




Q2: Write a program to print this triangle:
*
**
*
****
*
******
*
********
*
**********
Don't use ten printf statements; use two nested loops instead. You'll have to use braces around the body of the outer loop if it contains multiple statements.

#include
main()
{
int i,j;
clrscr();
printf("Triangle\n\n");
for(i=1;i<=10;i++)
{
/* if i is odd number print sigle star*/
if(i%2 != 0)
printf("*");
else
{
/* if i is even number*/
for(j=1;j<=i;j++)
{
printf("*");
}
}
printf("\n");
}
getche();
}



Q3: The standard library contains a function called atoi, which takes a string (presumably a string of digits) and converts it to an integer. For example, atoi(“345”) would return the integer 345. Write a program that reads lines (using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. Also compute the standard deviation.

#include
#include

main()
{
char str[40];
int i,l,c=0;
clrscr();
printf("Enter line no:");
scanf("%d",&l);
for(i=0;i<=l;i++)
{
gets(str);
c=c+atoi(str); s
}
printf("Avg is: %f",(float)c/l);
getche();
}






Q4: Write the function int countchtr(char string[ ], int ch);
which returns the number of times the character ch appears in the string. For example, the call
countchtr(“She lives in NEWYORK”, ‘e’)
would return 3.

#include
#define Max 50
int countchar(char[Max], char);

main()
{
char str1[Max],ch1;
int c;
clrscr();
printf("Enter string: ");
gets(str1);
printf("Enter char which u want to count: ");
scanf("%c",&ch1);
c = countchar(str1,ch1);
printf("Count is: %d",c);
getch();
}
int countchar(char str[], char ch)
{
int i,count=0;
for(i=0;i{
if(str[i]==ch)
count = count+1;
}
return count;
}




Q5:

Write a program that takes three variables (a, b, c) in as separate parameters and rotates the values stored so that value a goes to b, b, to c and c to a.

#include
main()
{
char ch1;
char ch2;
char ch3;
char temp;
clrscr();
printf("Enter characters: \n");
scanf("%c %c %c",&ch1,&ch2,&ch3);
printf("Rotated list is: \n");
temp = ch1;
ch1 = ch2;
ch2 = ch3;
ch3 = temp;
printf("%c\t",ch1);
printf("%c\t",ch2);
printf("%c",ch3);
getche();
}


for more information contact at : masteragarwal@yahoo.com







Website counter