Friday, January 25, 2013

Cascading Style Sheet inline & internal example


<!--Example of Cascading Style Sheet with inline & internal....fensasaj@blogspot.com-->
<html>
<head>
<style>
body
{
background-color:lightblue;
}
h1
{
color:red;
text-align:center;
}
h4
{
text-align:left;
background-color:pink;
color:green;
}
p
{
font-family:"Palace Script MT";
font-size:70px;
color:blue;
}
</style>
</head>
<body>
<h1>WELCOME</h1>
<h4>Log onto e-mail</h4>
<p>This is first page...........................
Welcome to first page...........................
Keep trying.....................................
</p>
</body>
</html>

Validation of Username and Password


<!--Validation of Username and Password........fensasaj@blogspot.com-->
<html>
<head>
</head>
<body bgcolor="cyan">

<form>

<h3 align="center">username<input type="text" name="userid"/>
</h3>
<br>
<h3 align="center">password<input type="password" name="password"/>
</h3>
<br>
<input type ="button" onclick="check(this.form)" value="submit"/>

<input type="reset" value="reset"/>

</form>

<script language="javascript">

function check(form)
{
 if(form.userid.value=="lbs"&&form.password.value=="it")
 {
  document.write("Welcome lbs!!");
 }
 else
 {
  alert("you are a wrong user");
 }
}

</script>

</body>

</html>

Calculator using Javascript


<!--Creating Calculator using Javascript....fensasaj@blogspot.com-->
<html>
<head>
<script type="text/javascript">

function pushButton(buttonValue) {
     if (buttonValue == 'C') {
          document.getElementById('screen').value = '';
     }
     else {
          document.getElementById('screen').value += buttonValue;
     }
}
function calculate(equation) {
     var answer = eval(equation);
     document.getElementById('screen').value = answer;

}
</script>
</head>
<body>
<style type="text/css">
table.calc {
     border: 2px solid #0034D1;
     background-color: #809FFF;
}
input.calc {
     width: 100%;
     margin: 5px;
}
</style>
<fieldset>
<legend>Calculator</legend>
<table class="calc" cellpadding=4>
<tr><td colspan=3><input class="calc" id="screen" type="text"></td></tr>
<tr>
<td><input class="calc" type="button" value=1 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value=2 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value=3 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value='/' onclick="pushButton(this.value);"></td>
</tr>
<tr>
<td><input class="calc" type="button" value=4 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value=5 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value=6 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value='*' onclick="pushButton(this.value);"></td>
</tr>
<tr>
<td><input class="calc" type="button" value=7 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value=8 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value=9 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value='-' onclick="pushButton(this.value);"></td>
</tr>
<tr>
<td><input class="calc" type="button" value=0 onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value='.' onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value='C' onclick="pushButton(this.value);"></td>
<td><input class="calc" type="button" value='+' onclick="pushButton(this.value);"></td>
</tr>
<tr><td colspan=3><input class="calc" type="button" value='=' onclick="calculate(document.getElementById('screen').value);"></td></tr>
</table>
</body>
</html>

Online QUIZ using Javascript


<!--ONLINE QUIZ example ......fensasaj@blogspot.com.-->
<HEAD>
     
    <SCRIPT LANGUAGE="JavaScript">
   
     
    var ans = new Array;
    var done = new Array;
    var score = 0;
    ans[1] = "c";
    ans[2] = "a";
    ans[3] = "b";
    ans[4] = "b";
    ans[5] = "d";
 
    function Pop(question, answer) {
    if (answer != ans[question]) {
    if (!done[question]) {
    done[question] = -1;
    alert("Wrong! and Your score is now: " + score);
    }
    else {
    alert("You have already answered that!");
       }
    }
    else {
    if (!done[question]) {
    done[question] = -1;
    score++;
    alert("Correct!and Your score is now: " + score);
    }
    else {      
    alert("You have already answered that!");
          }
       }
    }
         
    function NextLevel () {
    if (score > 5) {
    alert("Cheater!");
    }
    if (score >= 3 && score <= 6) {
    alert("Access permitted!  But there are no more levels if you don't make any ...")
     
    //change previous line to: self.location="js_misc_userquiz2.html" if you make more
     
    }
    else {
    alert("Access denied!  You need 3 points to enter the next level.")
       }
    }
   
    </SCRIPT>
     
 
     
    <BODY>
     
    <font size=7 face=Arial>Online Quiz</font><br><p>
    <b>Objective: answer 3 questions correctly.  JavaScript required!</b><p>
    <noscript>JavaScript is <b><i>disabled</b></i>.  Get Netscape 3.0 or turn it on!</noscript>
    <hr noshade>
    <FORM>
    <b>1. Which is the capital of  <i>Canada</i>?</b><p>
    <input type=radio value="a" onClick="Pop(1, this.value)">Doha<br>
    <input type=radio value="b" onClick="Pop(1, this.value)">Canbera<br>
    <input type=radio value="c" onClick="Pop(1, this.value)">Ottawa<br>
    <input type=radio value="d" onClick="Pop(1, this.value)">Vienna<p>
    <b>2. Where is the head quarters of <i>UNESCO</i>?</b><p>
    <input type=radio value="a" onClick="Pop(2, this.value)">Paris<br>
    <input type=radio value="b" onClick="Pop(2, this.value)">Switzerland<br>
    <input type=radio value="c" onClick="Pop(2, this.value)">Brazil<br>
    <input type=radio value="d" onClick="Pop(2, this.value)">Delhi<p>
    <b>3. Which is the first country to introduce currency notes ?</b><p>
    <input type=radio value="a" onClick="Pop(3, this.value)">India<br>
    <input type=radio value="b" onClick="Pop(3, this.value)">China<br>
    <input type=radio value="c" onClick="Pop(3, this.value)">Pakisthan<br>
    <input type=radio value="d" onClick="Pop(3, this.value)">Sri Lanka<p>
    <b>4. Who is the first Indian Nobel Laurette?</b><p>
    <input type=radio value="a" onClick="Pop(4, this.value)">Amartya Sen<br>
    <input type=radio value="b" onClick="Pop(4, this.value)">Rabindra Nath Tagore<br>
    <input type=radio value="c" onClick="Pop(4, this.value)">Indira Gandhi<br>
    <input type=radio value="d" onClick="Pop(4, this.value)">Mother Theresa<p>
    <b>5. Who invented Radio? </b><p>
    <input type=radio value="a" onClick="Pop(5, this.value)">Edison<br>
    <input type=radio value="b" onClick="Pop(5, this.value)">Bell<br>
    <input type=radio value="c" onClick="Pop(5, this.value)">Newton<br>
    <input type=radio value="d" onClick="Pop(5, this.value)">Marcony<p>
   
    <CENTER>
    <input type=button onClick="NextLevel()" value="Advance to next level">
    </CENTER>
    </FORM>                


Saturday, June 2, 2012


//fms
//multiple stack
#include<stdio.h>
#include<conio.h>
int st[20],size[20],lb,ub,t[10],j,d,n;
void setst(int i)
{
if(i==1)
{
lb=0;
ub=(n-1);
//printf("\n%d %d",lb,ub);
}
else
{
lb=(i-1)*n;
ub=(i)*n-1;
//printf("\n%d %d",lb,ub);
}
}

void initialise()
{
 int p;
 for(p=0;p<10;p++)
 {
  setst(p+1);
  t[p]=lb;
 }
}


void push(int itm,int i)
{
int top;
setst(i);
top=t[i-1];
if(top>ub)
{
printf("\nStack %d full!",i);
return;
}
else
{
st[top]=itm;
top++;
t[i-1]=top;
}
}


void pop(int i)
{
int top,itm;
setst(i);
top=t[i-1];;
if(top<lb)
printf("\nStack %d empty!",i);
else
{
itm=st[top];
st[top]=0;
top--;
t[i-1]=top;
}
}

void disp(int i)
{
int top,k;
setst(i);
top=t[i-1];
for(k=top-1;k>=lb;k--)
{
printf("\n%d\n",st[k]);
}
}

void main()
{
int i,index,itm,ch,w;
clrscr();
printf("\nEnter size of array:");
scanf("%d",&j);
printf("\nEnter how many stack?");
scanf("%d",&d);
n=(j/d);
initialise();
do
{
printf("\nEnter choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("\nEnter item:");
       scanf("%d",&itm);
       printf("\nEnter stack number:");
       scanf("%d",&i);
       setst(i);
       push(itm,i);
       break;
case 2:printf("\nEnter stack number:");
       scanf("%d",&i);
       pop(i);
       break;
case 3:printf("\nIndex of stack:");
       scanf("%d",&i);
       disp(i);
       break;
case 4:dispall(d);
       break;
case 5:exit(0);
}
}while(1);
getch();
}

 dispall(int d)
{
int k,index,i;
for(index=1;index<=d;index++)
{
printf("Stack number is %d\n",index);
setst(index);
for(k=ub;k>=lb;k--)
{
printf("\n%d\n",st[k]);
}
}
}

DATA STRUCTURES.-circular linked list

//fms
//program to implement circular linked list
#include<malloc.h>
#include<conio.h>
#include<stdio.h>
struct node
{
    int info;
    struct node *link;
}*last;
typedef struct node *nod;
void main()
{
    int ch,n,m,i,pos,c,k,a,ch1;
    last->link=last;
    clrscr();
    printf("\nMENU\n1.create\n2.dispaly in sorted order\n3.insert\n 1.front\n 2.end\n 3.any\n4.delete\n         1.front\n 2.end\n 3.any\n5.modify\n6.exit");
do
{
    printf("\nEnter choice:");
    scanf("%d",&ch);
    switch(ch)
    {
     case 1:printf("\nEnter the number of nodes:");
                scanf("%d",&n);
                for(i=0;i<n;i++)
                {
                    printf("\nEnter element:");
                    scanf("%d",&m);
                    create_l(m);
                }
                break;
  case 2:printf("\nElements in sorted order are.....\n");
            display();
             break;
  case 3:do
            {
                 printf("\nEnter your choice:");
                 scanf("%d",&c);
                 switch(c)
                {
case 1:printf("\nEnter the element");
                    scanf("%d",&m);
                     insertf(m);
                     break;
case 2:printf("\nEnter the element");
                    scanf("%d",&m);
                    inserte(m);
                    break;
case 3:printf("\nEnter the element");
                    scanf("%d",&m);
                    printf("\nEnter key:");
                    scanf("%d",&k);
                     inserta(k,m);
                      break;
default:printf("invalid choice");
               }
       printf("\nDo you need 2 continue 1.yes 2.no");
       scanf("%d",&a);
       }while(a==1);
       break;
case 4:do
       {
       printf("\nEnter your choice:");
       scanf("%d",&ch1);
       switch(ch1)
       {
case 1:delf();
      break;
case 2:dele();
      break;
case 3:printf("\nEnter the element");
      scanf("%d",&m);
      dela(m);
      break;
}
       printf("\nDo you need 2 continue 1.yes 2.no");
       scanf("%d",&a);
       }while(a==1);
       break;
case 5:printf("\nEnter the element");
       scanf("%d",&m);
       printf("\nEnter key:");
       scanf("%d",&k);
       modify(k,m);
       break;
case 6:exit(0);
}
}while(1);
getch();
}
create_l(int m)
{
 nod q,tmp;
tmp=malloc(sizeof(struct node));
tmp->info=m;
if(last->link==last)
{
tmp->link=last;
last->link=tmp;
}
else
{
q=last;
while(q->link!=last)
{
q=q->link;
}
tmp->link=last;
q->link=tmp;
}
disp();
return;
}

inserte(int m)
{
nod q,tmp;
tmp=malloc(sizeof(struct node));
tmp->info=m;
if(last->link==last)
{
tmp->link=last;
last->link=tmp;
}
else
{
q=last;
while(q->link!=last)
{
q=q->link;
}
tmp->link=last;
q->link=tmp;
disp();
}
return;
}

insertf(int m)
{
 nod tmp;
tmp=malloc(sizeof(struct node));
tmp->info=m;
tmp->link=last->link;
last->link=tmp;
disp();
return;
}

disp()
{
 nod q,c,t;
if(last->link==last)
printf("\nList empty");
q=last->link;
printf("->");
while(q!=last)
{
printf("%d->",q->info);
q=q->link;
}
return;
}

inserta(int key,int data)
{
 nod tmp,ptr;
tmp=malloc(sizeof(struct node));
if(tmp==NULL)
printf("\nInsertion not possible!");
else
{
ptr=last;
while(ptr->info!=key && ptr->link!=last)
{
ptr=ptr->link;
}
if(ptr->link==last)
printf("\n%d not found!",key);
else if(ptr->info==key)
{
tmp->link=ptr->link;
tmp->info=data;
ptr->link=tmp;
disp();
}
}
return;
}

display()
{
 nod q,c,p,t;
 //int t;
if(last->link==last)
printf("\nList empty");
for(q=last->link;q!=last;q=q->link)
{
for(c=q->link;c!=last;c=c->link)
{
if(q->info > c->info)
{
t=q->info;
q->info=c->info;
c->info=t;
}
}
}
q=last->link;
printf("->");
while(q!=last)
{
printf("%d->",q->info);
q=q->link;
}
//printf("%d",q->link);
return;
}

dele()
{
nod  ptr,ptr1;
ptr=last;
while(ptr->link!=last)
{
ptr1=ptr;
ptr=ptr->link;
}
ptr1->link=ptr->link;
free(ptr);
disp();
return;
}

delf()
{
 nod prev,cur,q;
if(last->link==last)
printf("\nLIst empty");
else
{
prev=last->link;
cur=prev->link;
last->link=cur;
//cur->link=NULL;
free(prev);
disp();
}
return;
}

dela(int m)
{
 nod  ptr,ptr1;
ptr=last;
ptr1=ptr->link;
while(ptr->link!=last && ptr->info!=m)
{
ptr1=ptr;
ptr=ptr->link;
}
if(ptr->info==m)
{
ptr1->link=ptr->link;
free(ptr);
disp();
}
else
printf("\n%d not found!",m);
return;
}

modify(int key,int data)
{
 nod prev,cur;
cur=last;
while(cur->link!=last && cur->info!=key)
{
prev=cur;
cur=cur->link;
}
if(cur->info==key)
cur->info=data;
if(cur->link==last && cur->link!=key)
printf("\n%d not found!",key);
else
disp();
return;
}