You are on page 1of 29

1 *PROGRAM TO SHOW HOW TO USE LINKS* <HTML> <HEAD> </HEAD> <BODY> <B><FONT SIZE=5><P>GENERAL TABLE OF CONTENTS</P> </FONT><P>So you

want to make a Web page</P></B>LESSONS: <P><A HREF="../../makapage/introduction.htm">Introduction</A></P> <A HREF="../../makapage/lesson01.html">lesson1</A>:getting started,savingas html<BR> <A HREF="../../makapage/lesson02.html">Lesson2</A>:backgrounds, bold, italic, font, and fontsize<BR> <A HREF="../../makapage/lesson03.html">Lesson3</A>:basic formatting, line breaks, inserting images<BR> <A HREF="../../makapage/lesson04.html">Lesson4</A>:links, images, thumbnails, anchors<BR> <A HREF="../../makapage/lesson05.html">Lesson5</A>:lists, more formatting,horizantal rules,comments<BR> <a HREF="../../makapage/lesson06.html">Lesson6</A>:more resourses<BR> <A HREF="../../makapage/picker/index.html">Colour picker</A><BR> <A HREF="../../makapage/dafonts/master.html">Handy Danty Font Viewer</A><BR> <A HREF="../../makapage/dafonts/index.html">(intro)</A><BR> <A HREF="../../makapage/special.html">Special characters</A><BR> <A HREF="../../makapage/upload.html">Upload your page to the Web</A><BR> <FONT SIZE =2><p></p></FONT></BODY> </HTML>

2 *PROGRAM TO ENTER AND DISPLAY EMPLOYEE DETAILS* <html> <body bgcolor="blue"> <font size=5 bgcolor="white"> <center> ENTER EMPLOYEE DETAILS </center> <form name ="emp" > <center> <table bgcolor="pink"> <tr> <td>Name</td> <td><input type="text" name="t1" size="30"></td> </tr> <tr> <td>DEPARTMENT</td> <td><input type="text" name="t2" size="30"></td> </tr> <tr> <td>SALARY</td> <td><input type="text" name="t3" size="30"></td> </tr> <tr> <td>DA PERCENTAGE</td> <td><input type="text" name="t4" size="30"></td> </tr> <td><input type="button" name="b1" onClick="calc()" value="CALCULATE"></td> </tr></table></form> </body> <head><title>EMPLOYEE DETAILS</TITLE> <script language="jscript"> function calc() { var name,dept,sal,da,total name=emp.t1.value dept=emp.t2.value sal=emp.t3.value da=emp.t4.value total=parseInt(sal)+parseInt(sal)*da/100 document.write("<font color=orange>") document.write("<br>Name=" +name) document.write("<br>Department=" +dept) document.write("<br>Total Salary=" +total) } </script> </head> </html>

3 *PROGRAM TO ALERT HOW MANY OPTIONS ARE SELECTED* <html> <head> <title>ignou</title> <script language="JavaScript"> function howMany(selectObject) { var numberSelected=0,i=0 for(var r=0; i<selectObject.options.length;i++) { if(selectObject.options[i].selected==true) numberSelected++ } return numberSelected } </script> </head> <body> <form name="selectForm"> <p> <b>choose some music types,then click the button below:</b> <br><select name="musicTypes" multiple> <option selected>r&b <option>blues <option>new age <option>classical <option>classical <option>opera </select> </p> <input type="button" value="how many are selected?" onClick="alert('number of options selected:'+ howMany(document.selectForm.musicTypes))"> </form> </body> </html>

4 *PROGRAM TO PRINT THE HOMEPAGE OF A BOOK STORE* <html> <head> <title>HomePage</title> <script Language="vbscript"> Option Explicit sub SubmitDetails() document.frmHome.submit End Sub Sub ClearAll() document.frmHome.txtName.value="" document.frmHome.txtCreditCard.value="" End Sub sub GoToPages() select case(Document.MenuOptions.D1.option(0).value) case"AllProducts" window.location="AllProducts.htm" case"Search Products" window.location="Search.htm" case"Order Status" window.location="OrderStatus.htm" case"New Arrivals" window.location="NewArrivals.htm" end select end sub </script></head> <body> <center> <b>FAXY BOOK STORE</b><center> <table width="415"><td width="100"> <img src="bookstore1.gif"width="300" border="0" height="300"> </td> <tr> <td width="6"> </td> <td width="248"> <form Name ="MenuOptions" method="Post "action="AllProducts.htm">

5 <select size="1" name="D1"> <option value="AllProducts"selected>AllProducts</option> <option value="Search Products">Search Products </option> <option value="Order Status">Order Status</option> <option value="New Arrivals">New Arrivals</option> </select><input type="submit" value="Submit" name="B1"></p> </form> </td> </table> <form Name="frmHome" method="Post"> <table> <tr> <td> User Name</td><td><input type="text" name="txtName" size="25" maxlength="100"></td> </tr> <tr> <td> Address</td><td><input type="text" name="txtAddress" size="25" maxlength="100"></td></tr> <tr> <td>Credit Card No.</td> <td><input type="password" name="txtCreditCard" size="25"></td> </tr> <tr> <td> Select Books</td><td><select name="BooksNames"> <option value="The White Tiger-Aravind Adiga">The White Tiger-Aravind Adiga </option> <option> Buyology=-Martin Lindstorm</option> <option>The Excile-Navtej Sarma</option> </select></td> </tr> <tr> <td> <input type="submit" value="Submit" name="btnSubmit" onClick="SubmitDetails()"></td> <td><input type="reset"value="Cancel" name="btnCancel" onClick="ClearAll()"></td></tr> </table> </form> </body> </html>

6 *PROGRAM TO CONVERT TEMPERATURE IN CELCIUS TO FAHRENHEIT AND VICEVERSA* <html> <body> <input type="button" value="Convert Celsius to Fahrenheit" onclick= "inputCels();"> <br> <br> <input type="button" value="Convert Fahrenheit to Celsius" onclick= "inputFah();"> </body> <head> <title>A Simple Page</title> <script language="JavaScript"> function inputCels() { var cels = prompt("Enter a temperature in Degrees Celsius","Enter a temperature"); ansFah = doFahCalc(cels); alert(cels + " Degrees Celsius is " + ansFah + " Degrees Fahrenheit"); } function inputFah() { var fah = prompt("Enter a temperature in Degrees Fahrenheit","Enter a temperature"); ansCel = doCelCalc(fah); alert(fah + " Degrees Fahrenheit is " + ansCel + " Degrees Celsius"); } function doCelCalc(fah) { var ans = ((Number(fah) - 32) / 1.8); return (ans); } function doFahCalc(cels) { var ans = ((1.8 * Number(cels)) + 32); return (ans); } </script> </head> </html>

7 *PROGRAM TO GET THE CURRENT DAY AND PRINT IT * <html> <head> </head> <body> <script language="JavaScript"> var d=new Date() theDay=d.getDay() switch(theDay) { case 1: document.write("<b>lazy monday</b>") break case 2: document.write("<b>holy teusday</b>") break case 3: document.write("<b>wednesday</b>") break; case 4: document.write("<b>mondy thursday</b>") break case 5: document.write("<b>good friday</b>") break case 6: document.write("<b>happy saturday</b>") break case 0: document.write("<b>sunday</b>") break } </script> </body> </html>

8 *PROGRAM TO INCLUDE ALL INPUT TYPES* <html> <head></head> <body> <form> <table> <tr> <td> Name</td> <td><input type="text" name="name"></td> </tr> <tr> <td>Address</td> <td><textarea rows="2" name="address"> </textarea></td> </tr> <tr> <td>Gender</td> <td><input type="radio" name="g1" value="male" checked>male</td> <td><input type="radio" name="g2" value="female"> female</td> </tr> <tr> <td> Hobby </td> <td><input type="checkbox" name="c1" value="reading">reading</td> <td><input type="checkbox" name="c2" value="travelling">Travelling</td> <td><input type="checkbox" name="c3" value="sports">Sports</td> </tr> <tr> <td>City</td> <td><select size="1" name="city"> <option>Kochi</option> <option>kozhikode</option> <option>kasargod</option> </td> </tr> <tr> <p align ="center"> <td width=100 colspan="2" rowspan> <input type="submit" name="Submit" value="submit"></td> <td><input type="Reset" name="reset" value="Reset"></td> </tr> </table> </form> </body> </html>

9 *PROGRAM TO CREATE A CALCULATOR USING VBSCRIPT* <html> <head> <title>CALCULATOR</title> <script language="vbscript"> dim i,j dim op1,op2,op,res Function digit(i) Select Case i case 1 document.frnCal.display.value=document.frnCal.display.value &"1" case 2 document.frnCal.display.value=document.frnCal.display.value &"2" case 3 document.frnCal.display.value=document.frnCal.display.value &"3" case 4 document.frnCal.display.value=document.frnCal.display.value &"4" case 5 document.frnCal.display.value=document.frnCal.display.value &"5" case 6 document.frnCal.display.value=document.frnCal.display.value &"6" case 7 document.frnCal.display.value=document.frnCal.display.value &"7" case 8 document.frnCal.display.value=document.frnCal.display.value &"8" case 9 document.frnCal.display.value=document.frnCal.display.value &"9" case 0 document.frnCal.display.value=document.frnCal.display.value &"0" End Select End Function Function operation(j) if j=1 then op1=document.frnCal.display.value op=1 document.frnCal.display.value="" End if if j=2 then op1=document.frnCal.display.value op=2 document.frnCal.display.value="" End if if j=3 then op1=document.frnCal.display.value op=3 document.frnCal.display.value=""

10 End if if j=4 then op1=document.frnCal.display.value op=4 document.frnCal.display.value="" End if if j=5 then op2=document.frnCal.display.value if op=1 then res=op1+op2 document.frnCal.display.value=res else if op=2 then res=op1-op2 document.frnCal.display.value=res else if op=3 then res=op1*op2 document.frnCal.display.value=res else if op=4 then if op2<>0 then res=op1/op2 document.frnCal.display.value=res else document.frnCal.display.value="ERROR" End if End if End if End if End if End if End Function Sub B1_onClick digit(1) End Sub Sub B2_onCLick

11 digit(2) End Sub Sub B3_onCLick digit(3) End Sub Sub B4_onCLick digit(4) End Sub Sub B5_onCLick digit(5) End Sub Sub B6_onCLick digit(6) End Sub Sub B7_onCLick digit(7) End Sub Sub B8_onCLick digit(8) End Sub Sub B9_onCLick digit(9) End Sub Sub B0_onCLick digit(0) End Sub Sub BP_onClick operation(1) End Sub Sub BS_onClick operation(2) End Sub

12 Sub BM_onClick operation(3) End Sub Sub BD_onClick operation(4) End Sub Sub BE_onClick operation(5) End Sub Sub BDOT_onClick operation(6) End Sub </script> </head> <body> <form name="frnCal"> <center> <table border="0" cellpadding="5" cellspacing="0" width="74" height="172"> <tr> <center><td colspan="4" width="499" height="25"> <p align="center"><input type="text" value="" name= "display" size="21"></p> </td> </center> </tr> <tr> <td width ="134" height="27" > <input type="button" value="7" name="B7"></td> <td width ="133" height="27"> <input type="button" name="B8" value="8"></td> <td width="138" height="27"> <input type="button" value="9" name="B9"></td> <td width="66"height="27"> <input type="button" name="BP" value="+"></td> </tr> <tr> <td width="134 height="27"> <input type="button" name="B4" value="4"></td> <td width="133" height="27" > <input type="button" value="5" name="B5"></td> <td width="138" height="27"> <input type="button" name="B6" value="6"></td> <td width="66" height="27"> <input type="button" name="BS" value="-"></td> </tr>

13 <tr> <td width="134" height="27"> <input type="button" name="B1" value="1"></td> <td width="133" height="27"> <input type="button" value="2" name="B2"></td> <td width="138" height="27"> <input type="button" value="3" name="B3"></td> <td width="66" height="27"> <input type="button" name="BM" value="*"></td> </tr> <tr> <td width="134" height="16"> <input type="button" name="B0" value="0"></td> <td width="133" height="16"> <input type="button" value="." name="BDOT"></td> <td width="138" height="16"> <input type="button" value="=" name="BE"></td> <td width="66" height="16"> <input type="button" name="BD" value="/"></td> </tr> </table> </center> </form> </body> </html>

14 /*PROGRAM TO READ THE ELEMENTS OF TWO ARRAYS AND PRINT THEIR (1)SUM (2)PRODUCT (3)DIFFERENCE*/ #include<stdio.h> #include<conio.h> #define n 5 #define m 5 void main() { int a[n][m], b[n][m],c[n][m],i,j,r,c1,choice; clrscr(); printf("enter the size of row and column\n"); scanf("%d""%d",&r,&c1); printf("Enter the elements of first matrix a[%d][%d]\n",i,j); scanf("%d",&a[i][j]); for(i=0;i<r;i++) { for(j=0;j<c1;j++) { scanf("%d",&a[i][j]); } } printf("Enter the elements of second matrix b[%d][&d]\n"); scanf("%d",&b[i][j]); for(i=0;i<r;i++) { for(j=0;j<c1;j++) { scanf("%d",&b[i][j]); } printf("Enter your choice:\n 1.Addition\n2.substraction\n3.Multiplication"); scanf("%d",&choice); switch(choice) { case 1: for(i=0;i<r;i++) { for(j=0;j<c1;j++) { c[i][j]=a[i][j]+b[i][j]; } } printf("The sum is%d\n",c[i][j]);

15 break; case 2: for(i=0;i<r;i++) { for(j=0;j<c1;j++) { c[i][j]=a[i][j]-b[i][j]; } } printf("The difference of the two matrix is%d",c[i][j]); break; case 3: for(i=0;i<r;i++) { for(j=0;j<c1;j++) { c[i][j]=a[i][j]*b[i][j]; } } printf("The product of the matrix is%d",c[i][j]); break; } } getch(); }

16 /*PROGRAM TO READ INTEGERS UNTIL A 0 IS ENTERED. IF IT ENCOUNTERS 0 AS INPUTTHEN IT SHOULD DISPLAY: (1)THE TOTAL NUMBER OF EVEN AND ODD INTEGERS. (2)AVERAGE VALUE OF EVEN INTEGERS. (3)AVERAGE VALUE OF ODD INTEGERS.*/ #include<stdio.h> #include<conio.h> void main() { int number,i,total_even=0,total_odd=0; float avg_even,avg_odd; int sum_even=0, sum_odd=0; clrscr(); do { printf("\nEnter the number(0 for exit):",number); scanf("%d",&number); if(number!=0) if(number%2==0) { total_even+=1; sum_even+=number; } else { total_odd+=1; sum_odd+=number; } } while(number!=0); { if(total_even!=0) avg_even=sum_even/total_even; if(total_odd!=0) avg_odd=sum_odd/total_odd; } printf("Total even numbers=%d\n",total_even); printf("Total odd numbers=%d\n",total_odd); printf("Average value of even numbers=%f\n",avg_even); printf("Average value of odd numbers=%f\n",avg_odd); getch(); }

17 /*PROGRAM TO CHECK WHETHER A GIVEN NUMBER IS A PERFECT NUMBER OR NOT.*/ #include<stdio.h> #include<conio.h> void main() { int number,i=1,sum=0; clrscr(); printf("ENTER THE NUMBER:\n"); scanf("%d",&number); while(i<number) { if(number%i==0) sum+=i; i++; } if(sum==i) { printf("NUMBER %d IS A PERFECT NUMBER\t",number); } else { printf("NUMBER %d IS NOT A PERFECT NUMBER\t",number); } printf("\n\nPRESS ANY KEY"); getch(); }

18 /*PROGRAM TO PRINT THE INVERSE OF A MATRIX*/ #include<stdio.h> #include<conio.h> #define n 3 #define m 3 void main() { int i,j,k,a[n][m]; float inv[n][m]; int i1,i2,j1,j2; int choice,delta; clrscr(); printf("Enter the values for matrix:"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("\n\nEnter the elements of a[%d][%d]:",i,j); scanf("%d",&a[i][j]); } } printf("\n\n Entered matrix is as below"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("%3d\t",a[i][j]); } printf("\n"); } printf("\nThe inverse of the matrix is as below"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { if(i==0) {i1=1;i2=2;} else if(i==1) {i1=0;i2=2;} else{i1=0;i2=1;} if(j==0) {j1=1;j2=2;} else if(j==1) {j1=0;j2=2;} else{j1=0;j2=1;} if(!((i+j)%2)) inv[j][i]=a[i1][j1]*a[i2][j2]-a[i1][j2]*a[i2][j1];

19 else inv[j][i]=(a[i1][j1]*a[i2][j2]-a[i1][j2]*a[i2][j1]); } } delta=0; for(i=0;i<3;i++) { for(j=0;j<3;j++) { inv[i][j]=inv[i][j]/delta; printf("%3.2f\t",inv[i][j]); } printf("\n"); } getch(); }

20 /*PROGRAM TO PROCESS THE DETAILS OF STUDENTS-EVALUVATION RECORDS USING STRUCTURE*/ #include<stdio.h> #include<conio.h> struct student { int rollno; char name[20]; char add[30]; int marks[3]; float avg; }st[2]; void main() { int i,j,sum=0; clrscr(); for(i=0;i<2;i++) { printf("Enter the name of the student\n"); scanf("%s",&st[i].name); printf("Enter the roll number of the student\n"); scanf("%d",&st[i].rollno); printf("Enter the address of student\n"); scanf("%s",st[i].add); for(j=0;j<3;j++) { printf("Enter the marks \n"); scanf("%d",&st[i].marks[j]); sum+=st[i].marks[j]; } st[i].avg=sum/3.0; } clrscr(); for(i=0;i<2;i++) { printf("Roll number is:%d\n",st[i].rollno); printf("Name is:%s\n",st[i].name); printf("Address is:%s\n",st[i].add); printf("Average Marks is:%f\n\n",st[i].avg); } getch(); }

21 /*PROGRAM TO RETURN THE LENGTH OF A STRING WITHOUT USING strlen C LIBRARY FUNCTION BUT USING POINTERS*/ #include<stdio.h> #include<conio.h> #include<ctype.h> #include<string.h> void main() { int i; char str[20]; clrscr(); printf("Enter the string:"); gets(str); i=0; while(*(str+i)!='\0') { i++; } printf("The lenght of the string %s is %d\n",str,i); getch(); }

22 /*PROGRAM TO CREATE A FILE ,OPEN IT,TYPE IN SOME CHARACTRS AND COUNT THE NUMBER OF CHARACTERS IN A FILE*/ #include<stdio.h> #include<conio.h> #include<string.h> #include<IO.h> void main() { char c; FILE*fp1,*fp2; char filename[20],filename2[24]; int charcount; long filesize(FILE*stream); clrscr(); printf("Enter the name of file:"); gets(filename); if((fp1=fopen(filename,"w"))==NULL) printf("Error in opening the file"); else { //read the character from the console and store it in the file c=getc(stdin); while(c!='\n') { fputc(c,fp1); c=getc(stdin); } } charcount=filesize(fp1); printf("\n No of characters in the file=%d",charcount); fclose(fp1); getch(); } long filesize(FILE*stream) { long curpos,length; curpos=ftell(stream); fseek(stream,0L,SEEK_END); length=ftell(stream); fseek(stream,curpos,SEEK_SET); return length; }

23 WRITE A PROGRAM TO ADD TWO NUMBERS PRESENT IN TWO CONSEQUETIVE MEMORYLOCATIONS AND STORE THE RESULT IN NEXT MEMORY LOCATION. dataseg SEGMENT a dw 0010H b dw 0005H c dw 2 DUP(0) dataseg Ends code SEGMENT ASSUME DA;dataseg,CS:code main PROC FAR MOV AX,dataseg MOV DS,AX MOV BX,OFFSET A MOV AX,[BX] ADC AX,WORD PTR[BX+2] MOV[BX+4],AX MOV [BX+6],DX MOV AX,4COOH INT 21H code ENDS MAIN ends END

24 WRITE A PROGRAM TO READ IN TWO DECIMAL INPUTS AND PRINT OUTTHEIR SUM,IN DECIMAL. dataseg SEGMENT SUM DW? dataseg ENDS code SEGMENT aSSUME DS;dataseg,CS,code main PROC FAR MOV AX,dataseg MOV DS,AX MOV AH,01 INT 21H SUB AL,30H ADC AX,BX MOV SUM,AX MOV AH,09 MOV DX,SUM INT 21H code ENDS main ENDP END

25 WRITE A PROGRAM WHICH WILL READ TWO DECIMAL INPUTS AND PRINT OUPUT THEIR SUM,IN DECIMAL DATA SEGMENT NUM1 DB ? NUM2 DB ? MSG DB 13,10,'ENTER DECIMAL NO BETWEEN 1 TO 9$' MSG2 DB 13,10,'ANSWER IS $' DATA ENDS CODE SEGMENT ASSUME CS :CODE,DS:DATA START MOV AX,DATA MOV DS,AX MOV AH,09 LEA DX,MSG INT 21H MOV AH,01 INT 21H MOV NUM1,AL MOV AH,09 LEA DX,MSG INT 21H MOV AH,O1 INT 21H MOV NUM2,AL MOV AH, ADD AL,NUM1 AAA MOV BX,AX PUSH AX MOV AH,09 LEA DX,MSG2 INT 21H MOV DL,30H ADD DL,BH MOV AH,02 INT 21H POP AX MOV DL,30H ADD DL,BL MOV AH,02 INT 21H ;INTERUPT FOR PROMPT MESSAGE

;READ FIRST NUMBER

;INTERUPT FOR PROMPT MESSAGE

;READ SECOND NUMBER

;ADD FIRST NUMBER IN NUM1 WITH AL ;ASCII ADJUST ;STORE ANSWER IN BX ;INTERRUPT FOR PROMPT MESSAGE

;DISPLAY THE RESULT IN BX

26

MOV AH,4CH INT 21H CODE ENDS END START

;RETURN TO DOS

27 WRITE A PROGRAM TO SEARCH FOR A CHARACTER IN A GIVEN STRING AND CALCULATE THE NUMBER OF OCCURANCE OF THE CHARACTER IN THE GIVEN STRING. DATA SEGMENT STRING DB"*ST*ST**" ;STRING FOR WHICH CHARACTER TO BE ;SEARCHED STRLEN DB $-STRING ;LENGTH OF THE STRING CHAR DB"*" ;CHARACTER TO BE SEARCHED NOOFOCCUR DB 0 ;STORAGE FOR THE ANSWER OF ;NUMBER OF OCCURANCE DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA,ES:DATA START: MOV AX ,DATA ;INITIALIZATION OF DATA AND CODE SEGMENT MOV DS,AX MOV ES,AX LEA DI,STRING MOV AL,CHAR AL MOV CL,STRLEN MOV CH,00 R:REPNE SCASB SCANNED IS NOT JNE EXIT INC NOOFOCCUR JMP R ;PUT LENGTH OF STRING IN CL ;SCAN THE STRIN CHARACTER TO E ;PUT THE OFFSET OF THE STRING IN DI ;PUT CHARACTER TO BE SEARCHED IN

;FOUNT OR TILL END OF STRING ;INCREMENT IF CHARACTER FOUND ;AND REPEAT ABOVE PROCESS TILL END ; OF STRING EXIT:MOV AH,4CH ;RETURN TO DOS INT 21H

CODE ENDS END START

28 WRITE A PROGRAM TO DETERMINE A GIVEN STRING IS A PALINDROME. IF YES OUTPUT THE MESSAGE"THE GIVEN STRING IS A PALINDROME". IF NO OUTPUT THE MESSAGE "NO IT IS NT A PALINDROME". FINDLEN MACRO STR,LEN MOV CX,0020 ;MAXIMUM LENGTH IN CX MOV AL,'$' ;COMPARE CHARACTER MOV DI,OFFSET STR ;GET FIRST LOCATION OF THE STRING REPNE SCASB ;REPEAT COMPARING OF STRING CHAR ;WITH CHAR'$'IN AL IS REACHED MOV AL,20 ;MAXIMUM CHARACTER ASSUMPTION SUB AL,CL ;SUBSTRACT FROM CL SUB AL,1 MOV LEN,AL ;STORE LENGTH OF STRING IN LEN ENDM DISPSTR MACRO STR MOV AH,09H LEA DX,STR INT 21H ENDM DATASEGMENT ;MACRO FOR DISPLAY

;START DATA SEGMENT

LEN DB? ;STORE THE LENGTH OF STRING DMSG DB 'THE GIVEN STRING IS PALINDROME$' NOMSG DB 'NO IT IS NOT A PALINDROME$' STRING DB'MADAM$' ;FIRST DTRING IS DEFINED DATA ENDS CODE SEGMENT ;START CODE SEGMENT START: ASSUME CS:CODE,DS:DATA MOV AX,DATA ;INITIALIZE DATA AND ;EXTRA SEGMENT REGISTER MOV DS,AX MOV ES,AX MOV CX,0020 ;COUNTER FOR THE LOOP CLD LEA DI STRING ;ADDRES OF LONGER STRING FINDLEN STRING,LEN;CALL MACRO FOR FIND LEN OF STRING CLD ;CLEAR DIRECTION FLAG LEA SI,STRING ;SET SI TO POINT THE START OF STRING LEA DI,STRING ;SET DI TO POINT TE END OF STRING MOV AH,00

29 MOV AL,LEN ADD DI,AX DEC DI MOV CH,1 ;SET THE COUNTER FOR FIRST CHAR MOV CL,LEN ;SET CL WITH LAST CHAR POSITION CMPSB ;COMPARE BOTH STRINGS JNE ENDCOMP DEC DI DEC CL INC CH CMP CL,CH ;IF CL<=CH OR CH++CL THE GIVEN STRING ;IS PALINDROME

JC DISM JNZ COMPARECONT DISM: DISPSTR DMSG MESSAGE JMP E ENDCOMP: DISPSTR NOMSG E: MOV AH,4CH INT 21H CODE ENDS END START ;PRINT STRING IS PALINDROME

;PRINT NOT PALINDROME MESSAGE

;RETURN TO DOS

You might also like