Search This Blog

Thursday, April 4, 2013

JavaScript Rotating Banner..!

Hello, All... Below shown is a code for Javascript Banner Rotation.
You can use this code for displaying Advertisement in your webpage.
Also include this CSS(rotat.css) file for setting absolute  position and z-index property.


1.) rotat.css


2.) rotate.html

                                                     N'joy Friends..!

Thursday, March 7, 2013

How to disable Back Button using JavaScript..?

There are sometimes requirements when you have to disable your browser back button,so it won't go to previous pages. For example, when you press log-out and then on the current page the back-button or Backspace key should be disabled to maintain security...



So here is a code for javascript.
Put this snipt on  pages when you require this disabled back-button functionality:




<SCRIPT type="text/javascript">                          
 window.history.forward();                               
 function noBack() { window.history.forward(); }         
</SCRIPT>                                                
</HEAD>                                                  
<BODY onload="noBack();"                                 
 onpageshow="if (event.persisted) noBack();" onunload="">




Tuesday, February 7, 2012

Mid-Point Ellipse Drawing Algorithm..!!

Mid-Point Elliplse ( XC, YC, RX, RY):

Description: Here XC and YC denote the x – coordinate and y – coordinate of the center of the
ellipse and RX and RY denote the x – radius and y – radius respectively.

1.  Set RXSq = RX * RX
2.  Set RYSq = RY * RY
3.  Set X = 0 and Y = RY
4.  Set PX = 0 and PY = 2 * RXSq * Y
5.  Call Draw Elliplse(XC, YC, X, Y)
6.  Set P = RYSq – (RXSq * RY) + (0.25 * RXSq)                                            [Region 1]
7.  Repeat While (PX < PY)
8.    Set X = X + 1
9.    PX = PX + 2 * RYSq
10.    If (P < 0) Then
11.      Set P = P + RYSq + PX
12.    Else
13.      Set Y = Y – 1
14.      Set PY = PY – 2 * RXSq
15.      Set P = P + RYSq + PX – PY
    [End of If]
16.    Call Draw Elliplse(XC, YC, X, Y)
  [End of Step 7 While]
17.  Set P = RYSq*(X + 0.5)^2 + RXSq*(Y – 1)^2  – RXSq*RYSq                          [Region 2]
18.  Repeat While (Y > 0)
19.    Set Y = Y – 1
20.    Set PY = PY – 2 * RXSq
21.    If (P > 0) Then
22.      Set P = P + RXSq – PY
23.    Else
24.      Set X = X + 1
25.      Set PX + 2 * RYSq
26.      Set P = P + RXSq – PY + PX
    [End of If]
27.    Call Draw Ellipse(XC, YC, X, Y)
  [End of Step 18 While]
28.  Exit

Mid-Point Circle Drawing Algorithm..!!

Mid-Point Circle ( Xc, Yc, R):

Description: Here Xc and Yc denote the x – coordinate and y – coordinate of the center of the
circle. R is the radius.

1.  Set X = 0 and Y = R
2.  Set P = 1 – R
3.  Repeat While (X < Y)
4.    Call Draw Circle(Xc, Yc, X, Y)
5.    Set X = X + 1
6.    If (P < 0) Then
7.      P = P + 2X + 6
8.    Else
9.      Set Y = Y – 1
10.      P = P + 2(X – Y) + 1
    [End of If]
11.    Call Draw Circle(Xc, Yc, X, Y)
  [End of While]
12.  Exit

Draw Circle (Xc, Yc, X, Y):
1.  Call PutPixel(Xc + X, Yc, + Y)
2.  Call PutPixel(Xc - X, Yc, + Y)
3.  Call PutPixel(Xc + X, Yc, - Y)
4.  Call PutPixel(Xc - X, Yc, - Y)
5.  Call PutPixel(Xc + Y, Yc, + X)
6.  Call PutPixel(Xc - Y, Yc, + X)
7.  Call PutPixel(Xc + Y, Yc, - X)
8.  Call PutPixel(Xc - Y, Yc, - X)
9.  Exit

Line Drawing Algorithm: Bresenham Algorithm..!!

Bresenham Line ( X1, Y1, XN, YN):

Description: Here X1 and Y1 denote the starting x – coordinate and y  – coordinate of the line
and XN and YN denote the ending x – coordinate and y – coordinate.

1.  Set DX = XN – X1 and DY = YN – Y1
2.  Set Di = 2DY - DX
3.  Set DS = 2DY and DT = 2(DY – DX)
4.  Call PutPixel(X1, Y1)
5.  Repeat While (X1 < XN)
6.    Set X1 = X1 + 1
7.    If (Di < 0) Then
8.      Set Di = Di + DS
9.    Else
10.      Set Y1 = Y1 + 1
11.      Set Di = Di + DT
    [End of If]
12.    Call PutPixel(X1, Y1)
  [End of While]
13.  Exit

Line Drawing Algorithm: DDA Algorithm..!!

DDA Line ( X1, Y1, XN, YN):
Description: Here X1 and Y1 denote the starting x – coordinate  and y – coordinate  of the line
and XN and YN denote the ending x – coordinate and y – coordinate.

1.  Set M = (YN – Y1) / (XN – X1)    [Calculate slope of line]
2.  Repeat For I = X1 to XN
3.    If (M <= 1) Then
4.      Set DX = 1
5.      Set DY = M * DX
6.    Else
7.      Set DY = 1
8.      Set DX = DY / M
    [End of If]
9.    Set X1 = X1 + DX
10.    Set Y1 = Y1 + DY
11.    Call PutPixel(X1, Y1)
  [End of For]
12.  Exit

Saturday, September 10, 2011

A Program for Selection Sort Algorithm...!!

/*Selection sorting selects the initially the first element as minimum valued and compare it with the all elements*/
***************************************************************************
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define FNAME1 "best case"
#define FNAME2 "avg case"
#define FNAME3 "wrost case"

FILE *f1,*f2,*f3;
void main()
{
 int i,j,ch,n,k,min,minpos,a[10000];
 int count=0;
 clrscr();
 printf("1-> Best case\t2-> Average case\t 3-> Worst case\n\n");
 printf("Enter your choice:");
 scanf("%d",&ch);
 printf("Enter the size of elements of file\t:");
 scanf("%d",&n);


Friday, September 9, 2011

Insertion Sort Program..!!

/*This Program performs the Insertion Sort Algorithm using FILE Structer*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#define FNAME1 "best case"
#define FNAME2 "avg case"
#define FNAME3 "worst case"


FILE *f1,*f2,*f3;  //file pointer
void main()
{
 int i,j,ch,n,k,w,a[10000],c,temp;
 int cnt=0;
 clock_t start,end;
 clrscr();
 printf("1-> Best case\n2-> Average case\n 3-> Worst case\n\n");
 printf("Enter chice:");
 scanf("%d",&ch);
  printf("\nEnter size of elements in file\t:");
  scanf("%d",&n);
 switch(ch)
 {
  case 1:
   f1=fopen(FNAME1,"w");//here file will be created in TC, juss check it..!!
   for(i=0;i<n;i++)
   {
    a[i]=i;
    printf("%d ",a[i]);
    fprintf(f1,"%d\n",a[i]);
   }
   fclose(f1);

   i=0;
   f1=fopen(FNAME1,"r");
   while(!feof(f1))
   {
    fscanf(f1,"%d\n",&a[i]);
    printf("%d",a[i]);
    i++;
   }
   fclose(f1);


Friday, July 8, 2011

Sorting Algorithm_BUBBLE

/*Here is the program for bubble sorting..Enjoy Friends...!!!*/
#include<conio.h>
#include<stdio.h>
#define n 5
void main()
{
 int i,j,a[100],temp,count=0;
 clrscr();
 printf("Enter the elements\n");
 for(i=0;i<n;i++)
 {
  scanf("%d\n",&a[i]);
 }
 for(i=0;i<n;i++)
 {
  for(j=i;j<n;j++)
  {
   if(a[i]>a[j])
   {
    temp=a[i];
    a[i]=a[j];
    a[j]=temp;
    count++;                            //for counting complexity..
   }
  }
 }
 printf("\nAfter Sorting\n");
 for(i=0;i<n;i++)
 {
  printf("%d\n",a[i]);
 }
 printf("The no. of swapping required is:%d",count);
 getch();
}