Friday, 2 August 2013

DDA line algorithm

#include<stdio.h>
     #include<conio.h>
     #include<graphics.h>
     void main()
     {
    int x1,y1,xn,yn,X,Y,dx,dy,xinc,yinc,i,length;
     int gd=DETECT ,gm;
     initgraph(&gd,&gm,"C:\\TC\\BGI");
     printf("Enter the initial points:");
     scanf("%d%d",&x1,&y1);
     printf("Enter the end points:");
     scanf("%d%d",&xn,&yn);
     dx=xn-x1;
     dy=yn-y1;
     if(dx<=dy)
     {
     length=dy;
     }
     else
     {
     length=dx;
     }
     xinc=dx/length;
     yinc=dy/length;
     X=x1;
     Y=y1;
     i=1;
     putpixel(X,Y,RED);
     while(i<=length)
     {
      X=X+xinc;
      Y=Y+yinc;
      i++;
      putpixel(X,Y,RED);
      }
     getch();
     closegraph();
     }

Tuesday, 30 July 2013

To transfer a character from one computer to another.


To transfer a character from one computer to another.



Source Code at Transmitter side:


#include<iostream.h>
#include<dos.h>
#include<io.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
void main()
{
clrscr();
int choice;
cout<<"enter the choice\n";
cout<<"1: character transfer\n";
cout<<"2: string transfer\n";
cout<<"3: file transfer";
cin>>choice;*/
switch(choice)
{
case 1:
void c_transfer();
break;
case 2:
void s_transfer();
break;
case 3:
void f_transfer();
break;
default:
cout<<"Invalid choice";
}
void c_transfer()
{
char ch;
outport(0x3FB,0x8f);
outport(0x3f8,0x00);
outport(0x3f9,0x24);
outport(0x3f9,0x0f);
cout<<"the character recieved is";
cin>>ch;
outport(0x3fb,ch);
cout<<"data has been trasmitted";
getch();
}
oid s_transfer()
{
char s[10];
cout<<"enter the string to be transmitted";
for(i=0;i<10;i++)
{
cin<<s[i];
}
for(i=0;i<10;i++)
{
outport(0x3FB,0x8f);
outport(0x3f8,0x00);
outport(0x3f9,0x24);
outport(0x3f9,0x0f);
outport(0x3f8,s[i]);
}
cout<<"data has been trasmitted";
}
void f_transfer()
{
FILE *f1;
char ch;
f1=fopen("c:\test.txt","w");
while( (ch=getc(f1)) !=EOF)
{
ch=getc(f1);
cout<< ch;
outport(0x3f8,ch);
}
fclose(f1);
ch='0';
outport(0x3f8,ch);
cout<<"file is transmitted \n";
}
}


Source Code at Receiver side:


#include<iostream.h>
#include<dos.h>
#include<io.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
void main()
{
clrscr();
int choice;
cout<<"enter the choice\n";
cout<<"1: character transfer\n";
cout<<"2: string transfer\n";
cout<<"3: file transfer";
cin>>choice;
switch(choice)
{
case 1:
void c_transfer();
break;
case 2:
void s_transfer();
break;
case 3:
void f_transfer();
break;
default:
cout<<"Invalid choice";
}
void c_transfer()
{
char ch;
outport(0x3FB,0x8f);
outport(0x3f8,0x00);
outport(0x3f9,0x24);
outport(0x3f9,0x0f);
ch=inport(0x3f8);
cout<<"the character recieved is"<<ch;
getch();
}
void s_transfer()
{
char s[10];
for(i=0;i<10;i++)
{
outport(0x3FB,0x8f);
outport(0x3f8,0x00);
outport(0x3f9,0x24);
outport(0x3f9,0x0f);
s[i]=inport(0x3f8);
}
cout<<"the string recieved is"<<s;
}
void f_transfer()
{
FILE *f1;
char ch='1','0';
outport(0x3FB,0x8f);
outport(0x3f8,0x00);
outport(0x3f9,0x24);
outport(0x3f9,0x0f);
f1=fopen("c:\test.txt","w");
cout<<"recieving Data<<end;
while(c!='0')
{
ch=inport(0x3f8);
if(a==c)
{
break;
}
cout<<'l';
cout<<ch;
fclose(f1);
cout<<"Data received";
getch();
}


Compilation /Running and Debugging the Solution

• Go to Compile Menu and Press the Compile for the Compilation of the code.
• If Successful Compilation is done then Run the Code Using ctrl + F9 key.
Before Compilation, following steps are to be followed:
• Step 1: Create a folder in either E or F drive with your Id Number or Name Followed by
RollNo.
• Step 2: Start the TC (Turbo C) from Desktop Icon or Go To Directory D:/TC/BIN/ and
run tc.exe . An Editor will be start.
• Step 3: Click on File Menu --> New. New (.cpp) file will be created. Again Click on File
-> Save. A dialog box will open. Write the path to your directory e.g. E:\CCN_Program
\FileName.CPP and Press OK. Now your cpp program will be saved in your directory.
• Step 4: Go To Option->Directories Check That Include Directory is set As D:\TC\Include
and Library Directory is set To D:\TC\LIB

Thursday, 25 April 2013

cookie


<html>
<head>
<script type="text/javascript">
function add_cookies()
{
var name=document.f1.t1.value;
dt= new Date();
var mts=dt.getDate(dt) + 1;
dt.setDate(mts);
document.write(dt);
document.cookie="name" + "=" + name + ";expires="+dt.toUTCString();
}
</script>
</head>
<body>
<form name=f1 method=post action=''>
<input type=text name=t1><input type=button onclick='add_cookies()'; value='Add Cookies'>
</form>
<br><br>
<a href=add-cookies.htm>Add Cookies</a> | <a href=read-cookies.htm>Read Cookies</a>
</body>
</html>

food menu


Foodmenu.xml
<?xml version="1.0"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
two of our famous Belgian Waffles with plenty of real maple syrup
</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>
light Belgian waffles covered with strawberries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>
light Belgian waffles covered with an assortment of fresh berries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>
thick slices made from our homemade sourdough bread
</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>
two eggs, bacon or sausage, toast, and our ever-popular hash browns
</description>
<calories>950</calories>
</food>
</breakfast_menu>

catlog


Catalog.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="exp8_b.css"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
<CD>
<TITLE>Greatest Hits</TITLE>
<ARTIST>Dolly Parton</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>RCA</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1982</YEAR>
</CD>
<CD>
<TITLE>Still got the blues</TITLE>
<ARTIST>Gary Moore</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Virgin records</COMPANY>
<PRICE>10.20</PRICE>
<YEAR>1990</YEAR>
</CD>
<CD>
<TITLE>Eros</TITLE>
<ARTIST>Eros Ramazzotti</ARTIST>
<COUNTRY>EU</COUNTRY>
<COMPANY>BMG</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1997</YEAR>
</CD>
<CD>
<TITLE>One night only</TITLE>
<ARTIST>Bee Gees</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Polydor</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1998</YEAR>
</CD>
<CD>
<TITLE>Sylvias Mother</TITLE>
<ARTIST>Dr.Hook</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS</COMPANY>
<PRICE>8.10</PRICE>
<YEAR>1973</YEAR>
</CD>
<CD>
<TITLE>Maggie May</TITLE>
<ARTIST>Rod Stewart</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Pickwick</COMPANY>
<PRICE>8.50</PRICE>
<YEAR>1990</YEAR>
</CD>
<CD>
<TITLE>Romanza</TITLE>
<ARTIST>Andrea Bocelli</ARTIST>
<COUNTRY>EU</COUNTRY>
<COMPANY>Polydor</COMPANY>
<PRICE>10.80</PRICE>
<YEAR>1996</YEAR>
</CD>
<CD>
<TITLE>When a man loves a woman</TITLE>
<ARTIST>Percy Sledge</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Atlantic</COMPANY>
<PRICE>8.70</PRICE>
<YEAR>1987</YEAR>
</CD>
<CD>
<TITLE>Black angel</TITLE>
<ARTIST>Savage Rose</ARTIST>
<COUNTRY>EU</COUNTRY>
<COMPANY>Mega</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1995</YEAR>
</CD>
<CD>
<TITLE>1999 Grammy Nominees</TITLE>
<ARTIST>Many</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Grammy</COMPANY>
<PRICE>10.20</PRICE>
<YEAR>1999</YEAR>
</CD>
<CD>
<TITLE>For the good times</TITLE>
<ARTIST>Kenny Rogers</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Mucik Master</COMPANY>
<PRICE>8.70</PRICE>
<YEAR>1995</YEAR>
</CD>
<CD>
<TITLE>Big Willie style</TITLE>
<ARTIST>Will Smith</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1997</YEAR>
</CD>
<CD>
<TITLE>Tupelo Honey</TITLE>
<ARTIST>Van Morrison</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Polydor</COMPANY>
<PRICE>8.20</PRICE>
<YEAR>1971</YEAR>
</CD>
<CD>
<TITLE>Soulsville</TITLE>
<ARTIST>Jorn Hoel</ARTIST>
<COUNTRY>Norway</COUNTRY>
<COMPANY>WEA</COMPANY>
<PRICE>7.90</PRICE>
<YEAR>1996</YEAR>
</CD>
<CD>
<TITLE>The very best of</TITLE>
<ARTIST>Cat Stevens</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Island</COMPANY>
<PRICE>8.90</PRICE>
<YEAR>1990</YEAR>
</CD>
<CD>
<TITLE>Stop</TITLE>
<ARTIST>Sam Brown</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>A and M</COMPANY>
<PRICE>8.90</PRICE>
<YEAR>1988</YEAR>
</CD>
<CD>
<TITLE>Bridge of Spies</TITLE>
<ARTIST>T'Pau</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Siren</COMPANY>
<PRICE>7.90</PRICE>
<YEAR>1987</YEAR>
</CD>
<CD>
<TITLE>Private Dancer</TITLE>
<ARTIST>Tina Turner</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Capitol</COMPANY>
<PRICE>8.90</PRICE>
<YEAR>1983</YEAR>
</CD>
<CD>
<TITLE>Midt om natten</TITLE>
<ARTIST>Kim Larsen</ARTIST>
<COUNTRY>EU</COUNTRY>
<COMPANY>Medley</COMPANY>
<PRICE>7.80</PRICE>
<YEAR>1983</YEAR>
</CD>
<CD>
<TITLE>Pavarotti Gala Concert</TITLE>
<ARTIST>Luciano Pavarotti</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>DECCA</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1991</YEAR>
</CD>
<CD>
<TITLE>The dock of the bay</TITLE>
<ARTIST>Otis Redding</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Atlantic</COMPANY>
<PRICE>7.90</PRICE>
<YEAR>1987</YEAR>
</CD>
<CD>
<TITLE>Picture book</TITLE>
<ARTIST>Simply Red</ARTIST>
<COUNTRY>EU</COUNTRY>
<COMPANY>Elektra</COMPANY>
<PRICE>7.20</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Red</TITLE>
<ARTIST>The Communards</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>London</COMPANY>
<PRICE>7.80</PRICE>
<YEAR>1987</YEAR>
</CD>
<CD>
<TITLE>Unchain my heart</TITLE>
<ARTIST>Joe Cocker</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>EMI</COMPANY>
<PRICE>8.20</PRICE>
<YEAR>1987</YEAR>
</CD>
</CATALOG>
Catalog.css
CATALOG
{
background-color: #ffffff;
width: 100%;
}
CD
{
display: block;
margin-bottom: 30pt;
margin-left: 0;
}
TITLE
{
color: #FF0000;
font-size: 20pt;
}
ARTIST
{
color: #0000FF;
font-size: 20pt;
}
COUNTRY,PRICE,YEAR,COMPANY
{
display: block;
color: #000000;
margin-left: 20pt;
}

asp response


Form_response.asp
<html>
<head>
<title>Responding to a form</title>
</head>
<body>
Your name is <% =Request.Form("name") %> <BR>
Your email is <% =Request.Form("email") %>
</body>
</html>
Form_response.html
<html>
<head>
<title>Asking for information</title>
</head>
<body>
<form method="post" action="form_response.asp">
Your name: <input type="text" name="name" size="20"><BR>
Your email: <input type="password" name="email" size="15"><BR>
<input type="Submit" value="Submit">
</form>
</body>
</html>

session


Session.asp
<html>
<body>

<%
response.write("<p>")
response.write("Default Timeout is: " & Session.Timeout & " minutes.")
response.write("</p>")

Session.Timeout=30

response.write("<p>")
response.write("Timeout is now: " & Session.Timeout & " minutes.")
response.write("</p>")
%>

</body>
</html>
Index.asp
<html>
<head>
<title>Responding to a form</title>
</head>
<body>
Your name is <% =Request.Form("name") %> <BR>
Your email is <% =Request.Form("email") %>
</body>
</html>
Page1.asp
<% IF Session("permission")="YES" THEN %>
<html>
<title>Page 1</title>
<body>

Hi <% =Session("username") %>, welcome to Page 1 <BR>
This page is empty at the moment, but it will be very interesting in the next future

</body>
</html>

<% ELSE %>

You are not allowed to access this page

<% end IF %>
Respondtoform.asp
<% IF Request.form="" THEN %>
<html>
<title>Our private pages</title>
<body>
In order to access this pages fill the form below:<BR>
<form method="post" action="index.asp">
Username: <input type="text" name="username" size="20"><BR>
Password: <input type="password" name="password" size="15"><BR>
<input type="Submit" value="Submit">
</form>
</body>
</html>

<% ELSE %>

<%
IF Request.form("username")="Joe" AND Request.form("password")="please" THEN
%>
<%
Session("permission")="YES"
Session("username")="Joe"
%>

<html>
<title>Our private pages</title>
<body>

Hi <% =Session("username") %>, you are allow to see these pages: <BR>
<A HREF="page1.asp">Page 1</A><BR>
<A HREF="page2.asp">Page 2</A>

</body>
</html>

<% ELSE %>

Error in username or password

<% END IF %>

<% END IF %>