tag:blogger.com,1999:blog-80975392852947301922024-03-13T22:33:36.968+05:30Computer EngineeringHere, you will find many known problems of computer engg. and solution of this..meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-8097539285294730192.post-24589192125060302262013-04-04T11:36:00.000+05:302013-04-04T11:36:58.109+05:30JavaScript Rotating Banner..!<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Hello</b>, All...
Below shown is a code for Javascript Banner Rotation.<br />
You can use this code for displaying Advertisement in your webpage.<br />
Also include this CSS(rotat.css) file for setting absolute position and z-index property.<br />
<br />
<br />
<span style="color: red;"><u><b>1.) rotat.css</b></u></span><br />
<textarea class="txtarea-medium" cols="70" readonly="readonly" rows="10">/* CSS Document */
#block img{
position:absolute;
width:200px;
z-index=1;
}
</textarea>
<br />
<br />
<span style="color: red;"><u><b>2.) rotate.html</b></u></span><br />
<textarea class="txtarea-medium" cols="70" readonly="readonly" rows="40"><html>
<head>
<title>Rotate</title>
<link rel="stylesheet" type="text/css" href="rotat.css" />
<script type="text/javascript">
var cur=1;
function rotate(){
if(cur<=5){
document.getElementById('i'+cur).style.zIndex+=1;
++cur;
}
else{
cur=1;
}
}
function strtRotate(){
setInterval("rotate()",700);
}
</script>
</head>
<body onload="return strtRotate()">
<div id="block" align="center">
<img src="1.png" id="i1"/>
<img src="2.png" id="i2"/>
<img src="3.png" id="i3"/>
<img src="4.png" id="i4"/>
<img src="5.png" id="i5"/>
</div>
</body>
</html>
</textarea><br />
<span style="color: blue;"><i><b> N'joy Friends..!</b></i></span> </div>
meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com1tag:blogger.com,1999:blog-8097539285294730192.post-74830380845726306372013-03-07T22:04:00.001+05:302013-03-07T22:08:12.507+05:30How to disable Back Button using JavaScript..?<div dir="ltr" style="text-align: left;" trbidi="on">
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...<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-AyTDM_wLsNs/UTjBBHp_6oI/AAAAAAAAArk/JvxhsC7ApyM/s1600/back1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-AyTDM_wLsNs/UTjBBHp_6oI/AAAAAAAAArk/JvxhsC7ApyM/s320/back1.jpg" title=" " width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-gxDB0Ub_ZRw/UTjBCc3G56I/AAAAAAAAArs/W4WVZk_8NMc/s1600/back.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-gxDB0Ub_ZRw/UTjBCc3G56I/AAAAAAAAArs/W4WVZk_8NMc/s1600/back.jpg" title=" " /></a></div>
<br />
So here is a code for javascript.<br />
Put this snipt on pages when you require this disabled back-button functionality:<br />
<br />
<br />
<span style="background-color: yellow;"><span style="color: red;"><br /></span></span>
<br />
<pre class="brush: xml; title: ; notranslate" title=""><span style="background-color: yellow;"><span style="color: red;"><SCRIPT type="text/javascript">
window.history.forward();
function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"
onpageshow="if (event.persisted) noBack();" onunload=""></span></span></pre>
<pre class="brush: xml; title: ; notranslate" title=""><span style="background-color: #999999;">
</span></pre>
<pre class="brush: xml; title: ; notranslate" title=""><span style="background-color: #999999;">
</span></pre>
<pre class="brush: xml; title: ; notranslate" title=""><span style="background-color: #999999;">
</span></pre>
<pre class="brush: xml; title: ; notranslate" title=""><span style="background-color: #999999;">
</span></pre>
</div>
meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com0tag:blogger.com,1999:blog-8097539285294730192.post-63229893427963703702012-02-07T19:03:00.000+05:302012-02-07T19:03:46.054+05:30Mid-Point Ellipse Drawing Algorithm..!!<div dir="ltr" style="text-align: left;" trbidi="on"><u><b>Mid-Point Elliplse ( XC, YC, RX, RY): </b></u><br />
<br />
<b><i>Description:</i></b> Here XC and YC denote the x – coordinate and y – coordinate of the center of the <br />
ellipse and RX and RY denote the x – radius and y – radius respectively. <br />
<br />
1. Set RXSq = RX * RX <br />
2. Set RYSq = RY * RY <br />
3. Set X = 0 and Y = RY <br />
4. Set PX = 0 and PY = 2 * RXSq * Y <br />
5. Call Draw Elliplse(XC, YC, X, Y) <br />
6. Set P = RYSq – (RXSq * RY) + (0.25 * RXSq) [Region 1] <br />
7. Repeat While (PX < PY) <br />
8. Set X = X + 1 <br />
9. PX = PX + 2 * RYSq <br />
10. If (P < 0) Then <br />
11. Set P = P + RYSq + PX <br />
12. Else <br />
13. Set Y = Y – 1 <br />
14. Set PY = PY – 2 * RXSq <br />
15. Set P = P + RYSq + PX – PY <br />
[End of If] <br />
16. Call Draw Elliplse(XC, YC, X, Y) <br />
[End of Step 7 While] <br />
17. Set P = RYSq*(X + 0.5)^2 + RXSq*(Y – 1)^2 – RXSq*RYSq [Region 2] <br />
18. Repeat While (Y > 0) <br />
19. Set Y = Y – 1 <br />
20. Set PY = PY – 2 * RXSq <br />
21. If (P > 0) Then <br />
22. Set P = P + RXSq – PY <br />
23. Else <br />
24. Set X = X + 1 <br />
25. Set PX + 2 * RYSq <br />
26. Set P = P + RXSq – PY + PX<br />
[End of If] <br />
27. Call Draw Ellipse(XC, YC, X, Y) <br />
[End of Step 18 While] <br />
28. Exit </div>meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com0tag:blogger.com,1999:blog-8097539285294730192.post-23168006900408350682012-02-07T18:58:00.001+05:302012-02-07T18:58:46.017+05:30Mid-Point Circle Drawing Algorithm..!!<div dir="ltr" style="text-align: left;" trbidi="on"><u><b>Mid-Point Circle ( Xc, Yc, R): </b></u><br />
<br />
<b><i>Description: </i></b>Here Xc and Yc denote the x – coordinate and y – coordinate of the center of the <br />
circle. R is the radius. <br />
<br />
1. Set X = 0 and Y = R <br />
2. Set P = 1 – R <br />
3. Repeat While (X < Y) <br />
4. Call<i> Draw Circle(Xc, Yc, X, Y) </i><br />
5. Set X = X + 1 <br />
6. If (P < 0) Then <br />
7. P = P + 2X + 6 <br />
8. Else <br />
9. Set Y = Y – 1 <br />
10. P = P + 2(X – Y) + 1 <br />
[End of If] <br />
11. Call Draw Circle(Xc, Yc, X, Y) <br />
[End of While] <br />
12. Exit <br />
<br />
<b>Draw Circle (Xc, Yc, X, Y): </b><br />
1. Call PutPixel(Xc + X, Yc, + Y) <br />
2. Call PutPixel(Xc - X, Yc, + Y) <br />
3. Call PutPixel(Xc + X, Yc, - Y) <br />
4. Call PutPixel(Xc - X, Yc, - Y) <br />
5. Call PutPixel(Xc + Y, Yc, + X) <br />
6. Call PutPixel(Xc - Y, Yc, + X) <br />
7. Call PutPixel(Xc + Y, Yc, - X) <br />
8. Call PutPixel(Xc - Y, Yc, - X) <br />
9. Exit</div>meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com0tag:blogger.com,1999:blog-8097539285294730192.post-65717816401081067312012-02-07T18:56:00.000+05:302012-02-07T18:56:10.206+05:30Line Drawing Algorithm: Bresenham Algorithm..!!<div dir="ltr" style="text-align: left;" trbidi="on"><u><b>Bresenham Line ( X1, Y1, XN, YN): </b></u><br />
<br />
<i>Description</i>: Here X1 and Y1 denote the starting x – coordinate and y – coordinate of the line <br />
and XN and YN denote the ending x – coordinate and y – coordinate. <br />
<br />
1. Set DX = XN – X1 and DY = YN – Y1 <br />
2. Set Di = 2DY - DX <br />
3. Set DS = 2DY and DT = 2(DY – DX) <br />
4. Call PutPixel(X1, Y1) <br />
5. Repeat While (X1 < XN) <br />
6. Set X1 = X1 + 1 <br />
7. If (Di < 0) Then <br />
8. Set Di = Di + DS <br />
9. Else <br />
10. Set Y1 = Y1 + 1 <br />
11. Set Di = Di + DT <br />
[End of If] <br />
12. Call PutPixel(X1, Y1) <br />
[End of While] <br />
13. Exit</div>meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com0tag:blogger.com,1999:blog-8097539285294730192.post-42452469603114058162012-02-07T18:50:00.000+05:302012-02-07T18:50:31.967+05:30Line Drawing Algorithm: DDA Algorithm..!!<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-cnSni0VVQ7U/TzEk00FFjXI/AAAAAAAAAIY/60wtHGTDgJw/s1600/DDA_line.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="286" src="http://4.bp.blogspot.com/-cnSni0VVQ7U/TzEk00FFjXI/AAAAAAAAAIY/60wtHGTDgJw/s320/DDA_line.jpg" width="320" /></a></div><b><u>DDA Line ( X1, Y1, XN, YN): </u></b><br />
<b><i>Description</i></b>: Here X1 and Y1 denote the starting x – coordinate and y – coordinate of the line <br />
and XN and YN denote the ending x – coordinate and y – coordinate. <br />
<br />
1. Set M = (YN – Y1) / (XN – X1) [Calculate slope of line] <br />
2. Repeat For I = X1 to XN <br />
3. If (M <= 1) Then <br />
4. Set DX = 1 <br />
5. Set DY = M * DX <br />
6. Else <br />
7. Set DY = 1 <br />
8. Set DX = DY / M <br />
[End of If] <br />
9. Set X1 = X1 + DX <br />
10. Set Y1 = Y1 + DY <br />
11. Call PutPixel(X1, Y1) <br />
[End of For] <br />
12. Exit</div>meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com0tag:blogger.com,1999:blog-8097539285294730192.post-56822739982306889612011-09-10T13:35:00.001+05:302012-01-21T18:26:36.667+05:30A Program for Selection Sort Algorithm...!!<div dir="ltr" style="text-align: left;" trbidi="on">/*Selection sorting selects the initially the first element as minimum valued and compare it with the all elements*/<br />
***************************************************************************<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<stdlib.h><br />
#define FNAME1 "best case"<br />
#define FNAME2 "avg case"<br />
#define FNAME3 "wrost case"<br />
<br />
FILE *f1,*f2,*f3;<br />
void main()<br />
{<br />
int i,j,ch,n,k,min,minpos,a[10000];<br />
int count=0;<br />
clrscr();<br />
printf("1-> Best case\t2-> Average case\t 3-> Worst case\n\n");<br />
printf("Enter your choice:");<br />
scanf("%d",&ch);<br />
printf("Enter the size of elements of file\t:");<br />
scanf("%d",&n);<br />
<br />
<br />
<a name='more'></a> switch(ch)<br />
{<br />
case 1:<br />
f1=fopen(FNAME1,"w");<br />
for(i=0;i<n;i++)<br />
{<br />
a[i]=i;<br />
printf("%d\t",a[i]);<br />
fprintf(f1,"%d\n",a[i]);<br />
}<br />
fclose(f1);<br />
<br />
f1=fopen(FNAME1,"r");<br />
i=0;<br />
while(!feof(f1))<br />
{<br />
fscanf(f1,"%d\n",&a[i]);<br />
i++;<br />
}<br />
fclose(f1);<br />
<br />
for(i=0;i<n;i++) //sorting loop<br />
{<br />
min=a[i];<br />
minpos=i;<br />
for(j=i+1;j<n;j++)<br />
{<br />
if(min>a[j])<br />
{<br />
count++;<br />
min=a[j];<br />
minpos=j;<br />
}<br />
}<br />
a[minpos]=a[i];<br />
a[i]=min;<br />
} //sorting loop ends<br />
printf("After Sorting... \n");<br />
for(i=0;i<n;i++)<br />
{<br />
fscanf(f1,"%d\n",&a[i]);<br />
printf("%d\t",a[i]);<br />
}<br />
printf("The total counts required:%d",count);<br />
break;<br />
case 2:<br />
f2=fopen(FNAME2,"w");<br />
for(i=0;i<n;i++)<br />
{<br />
k=rand();<br />
fprintf(f2,"%d\t",k);<br />
}<br />
fclose(f2);<br />
f2=fopen(FNAME2,"r");<br />
i=0;<br />
while(!feof(f2))<br />
{<br />
fscanf(f2,"%d\t",&a[i]);<br />
printf("%d\t",a[i]);<br />
i++;<br />
}<br />
fclose(f2);<br />
for(i=0;i<n;i++) //sorting loop<br />
{<br />
min=a[i];<br />
minpos=i;<br />
for(j=i+1;j<n;j++)<br />
{<br />
if(min>a[j])<br />
{<br />
count++;<br />
min=a[j];<br />
minpos=j;<br />
}<br />
}<br />
a[minpos]=a[i];<br />
a[i]=min;<br />
} //sorting loop ends<br />
printf("After Sorting... \n");<br />
for(i=0;i<n;i++)<br />
{<br />
fscanf(f1,"%d\n",&a[i]);<br />
printf("%d\t",a[i]);<br />
}<br />
printf("The total counts required:%d",count);<br />
break;<br />
<br />
case 3:<br />
f3=fopen(FNAME3,"w");<br />
i=n-1;<br />
j=0 ;<br />
while(i>=0)<br />
{<br />
a[j]=i;<br />
fprintf(f3,"%d\n",a[i]);<br />
printf("%d\t",a[j]);<br />
i--;<br />
j++;<br />
}<br />
fclose(f3);<br />
for(i=0;i<n;i++) //sorting loop<br />
{<br />
min=a[i];<br />
minpos=i;<br />
for(j=i+1;j<n;j++)<br />
{<br />
if(min>a[j])<br />
{<br />
count++;<br />
min=a[j];<br />
minpos=j;<br />
}<br />
}<br />
a[minpos]=a[i];<br />
a[i]=min;<br />
} //sorting loop ends<br />
printf("After Sorting... \n");<br />
for(i=0;i<n;i++)<br />
{<br />
fscanf(f1,"%d\n",&a[i]);<br />
printf("%d\t",a[i]);<br />
}<br />
printf("The total counts required:%d",count);<br />
break;<br />
}<br />
getch();<br />
}<br />
****************************************************************************</div>meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com0tag:blogger.com,1999:blog-8097539285294730192.post-18397883687686236222011-09-09T23:18:00.001+05:302012-01-21T18:26:36.668+05:30Insertion Sort Program..!!<div dir="ltr" style="text-align: left;" trbidi="on"><b>/*This Program performs the Insertion Sort Algorithm using FILE Structer*/<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<stdlib.h><br />
#include<time.h><br />
#define FNAME1 "best case"<br />
#define FNAME2 "avg case"<br />
#define FNAME3 "worst case"</b><br />
<br />
<b>FILE *f1,*f2,*f3; //file pointer<br />
void main()<br />
{<br />
int i,j,ch,n,k,w,a[10000],c,temp;<br />
int cnt=0;<br />
clock_t start,end;<br />
clrscr();<br />
printf("1-> Best case\n2-> Average case\n 3-> Worst case\n\n");<br />
printf("Enter chice:");<br />
scanf("%d",&ch);<br />
printf("\nEnter size of elements in file\t:");<br />
scanf("%d",&n);<br />
switch(ch)<br />
{<br />
case 1:<br />
f1=fopen(FNAME1,"w");//here file will be created in TC, juss check it..!!<br />
for(i=0;i<n;i++)<br />
{<br />
a[i]=i;<br />
printf("%d ",a[i]);<br />
fprintf(f1,"%d\n",a[i]);<br />
}<br />
fclose(f1);</b><br />
<b> i=0;<br />
f1=fopen(FNAME1,"r");<br />
while(!feof(f1))<br />
{<br />
fscanf(f1,"%d\n",&a[i]);<br />
printf("%d",a[i]);<br />
i++;<br />
}<br />
fclose(f1);</b><br />
<br />
<a name='more'></a><b> start=clock();<br />
for(i=1;i<n;i++) //sorting loop<br />
{<br />
for(j=i+1;j>0;j--)<br />
{<br />
if(a[j]<a[j-1])<br />
{<br />
temp=a[j];<br />
a[j]=a[j-1];<br />
a[j-1]=temp;<br />
cnt++;<br />
}</b><br />
<b> }</b><br />
<b> }<br />
end=clock();<br />
printf("\nAfter sorting: \n");<br />
f1=fopen(FNAME1,"w");<br />
for(i=0;i<n;i++)<br />
{<br />
fscanf(f1,"%d\n",&a[i]);<br />
printf("%d\t ",a[i]);<br />
}<br />
fclose(f1);<br />
printf("\nThe Time taken=%f",(end-start)/CLK_TCK);<br />
printf("\nThe total counts required= %d",cnt);<br />
break;<br />
case 2:<br />
f2=fopen(FNAME2,"w");<br />
i=0;<br />
for(i=0;i<n;i++)<br />
{</b><br />
<b> k=rand();<br />
fprintf(f2,"%d\t",k);<br />
// printf("%d",a[i]);<br />
}<br />
fclose(f2);<br />
f2=fopen(FNAME2,"r");<br />
i=0;<br />
while(!feof(f2))<br />
{<br />
fscanf(f2,"%d\t",&a[i]);<br />
printf("%d\t",a[i]);<br />
i++;<br />
}<br />
fclose(f2);</b><br />
<b> start=clock();<br />
cnt=0;<br />
for(i=1;i<n;i++) //sorting loop<br />
{<br />
for(j=i+1;j>0;j--)<br />
{<br />
if(a[j]<a[j-1])<br />
{<br />
temp=a[j];<br />
a[j]=a[j-1];<br />
a[j-1]=temp;<br />
cnt++;<br />
}</b><br />
<b> }</b><br />
<b> }<br />
end=clock();</b><br />
<b> printf("\nAfter sorting: \n");<br />
f2=fopen(FNAME2,"w");<br />
for(i=0;i<n;i++)<br />
{<br />
fscanf(f2,"%d\n",&a[i]);<br />
printf("\t%d ",a[i]);<br />
}<br />
fclose(f2);<br />
printf("\nThe TIME taken=%f",(end-start)/CLK_TCK);<br />
printf("\nThe total counts required= %d",cnt);<br />
break;</b><br />
<br />
<b> case 3:<br />
f3=fopen(FNAME3,"w");<br />
i=n-1;<br />
j=0 ;<br />
while(i>=0)<br />
{<br />
a[j]=i;<br />
fprintf(f3,"%d\n",a[i]);<br />
printf("%d\t",a[j]);<br />
i--;</b><br />
<b> j++;<br />
}<br />
fclose(f3);</b><br />
<b> f3=fopen(FNAME3,"r");<br />
i=0;<br />
while(!feof(f3))<br />
{<br />
fscanf(f3,"%d\t",&a[i]);<br />
printf("%d\t",a[i]);<br />
i++;<br />
}<br />
fclose(f3);</b><br />
<br />
<b> start=clock();<br />
cnt=0;<br />
for(i=1;i<n;i++) //sorting loop<br />
{<br />
for(j=i+1;j>0;j--)<br />
{<br />
if(a[j]<a[j-1])<br />
{<br />
temp=a[j];<br />
a[j]=a[j-1];<br />
a[j-1]=temp;<br />
cnt++;<br />
}</b><br />
<b> }</b><br />
<b> }<br />
end=clock();</b><br />
<b> printf("\nAfter sorting:");<br />
f3=fopen(FNAME3,"w");<br />
for(i=0;i<n;i++)<br />
{<br />
fscanf(f3,"%d\n",&a[i]);<br />
printf("%d ",a[i]);<br />
}<br />
fclose(f3);<br />
printf("\nThe TIME taken=%f",(end-start)/CLK_TCK);<br />
printf("\nThe total counts required= %d",cnt);<br />
break;</b><br />
<b> }<br />
getch();<br />
}</b><br />
<b>/*Enjoy FrenZZ*/</b></div>meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com0tag:blogger.com,1999:blog-8097539285294730192.post-33403546848863620172011-07-08T22:10:00.000+05:302011-08-29T19:25:18.673+05:30Sorting Algorithm_BUBBLE/*Here is the program for bubble sorting..Enjoy Friends...!!!*/<br />
#include<conio.h><br />
#include<stdio.h><br />
#define n 5<br />
void main()<br />
{<br />
int i,j,a[100],temp,count=0;<br />
clrscr();<br />
printf("Enter the elements\n");<br />
for(i=0;i<n;i++)<br />
{<br />
scanf("%d\n",&a[i]);<br />
}<br />
for(i=0;i<n;i++)<br />
{<br />
for(j=i;j<n;j++)<br />
{<br />
if(a[i]>a[j])<br />
{<br />
temp=a[i];<br />
a[i]=a[j];<br />
a[j]=temp;<br />
count++; //for counting complexity..<br />
}<br />
}<br />
}<br />
printf("\nAfter Sorting\n");<br />
for(i=0;i<n;i++)<br />
{<br />
printf("%d\n",a[i]);<br />
}<br />
printf("The no. of swapping required is:%d",count);<br />
getch();<br />
}meet_mehttp://www.blogger.com/profile/13971144356106711698noreply@blogger.com0