CAPTCHA Client (Java)

import java.util.*; import java.io.*; import java.net.*; import java.awt.*; import java.awt.image.*; import javax.swing.*; import javax.imageio.*; class ImagePanel extends JPanel { BufferedImage img; ImagePanel(BufferedImage img) { this.img = img; } public void paint(Graphics g) { g.drawImage(img, 0, 0, this); } } class CaptchaClient { static BufferedImage img; public static void main(String args[]) throws Exception { JFrame frame = new JFrame(); Scanner scan = new Scanner(System.in); System.out.println(“Connecting to … Continue reading CAPTCHA Client (Java)

Buffer Overflow problem (C)

#include <stdio.h> #include <string.h> int main(void) { char buff[15]; buff[14] = 0; printf(“\n Enter the password : \n”); gets(buff); if(strcmp(buff, “password”)) { printf (“\n Wrong Password \n”); } else { printf (“\n Correct Password \n”); buff[14] = 1; } if(buff[14]) { /* Now Give root or admin rights to user*/ printf (“\n Root privileges given to the user \n”); } return 0; } /* Output: … Continue reading Buffer Overflow problem (C)

All your Engineering Programs at one place

It’s not that easy to complete an experiment in 2 hours’ lab. Sometimes you finish up writing a program within just 15 minutes & sometimes even a whole week’s time is not enough to do so. We’re Engineers, we don’t need to copy everything word by word, but we need that one kick start. Once we get started, it’s tough to stop us. There are … Continue reading All your Engineering Programs at one place

Bezier Curve Algorithm (C++)

Problem Definition: Write a program to analyse and interpret the implementation of Bezier Curves. #include<iostream.h> #include<conio.h> #include<dos.h> #include<graphics.h> void main(){ int gd=DETECT,gm; initgraph(&gd,&gm,”C:\\TC\\BGI”); int x[4],y[4],px,py,i; cout<<“Enter four control points of bezier curve: “; for(i=0;i<4;i++) cin>>x[i]>>y[i]; double t; for(t=0.0;t<=1.0;t+=0.001){ px=(1-t)*(1-t)*(1-t)*x[0]+3*t*(1-t)*(1-t)*x[1]+3*t*t*(1-t)*x[2]+t*t*t*x[3]; py=(1-t)*(1-t)*(1-t)*y[0]+3*t*(1-t)*(1-t)*y[1]+3*t*t*(1-t)*y[2]+t*t*t*y[3]; putpixel(px,py,WHITE); delay(2); } getch(); closegraph(); } Continue reading Bezier Curve Algorithm (C++)

Sutherland-Hodgeman Polygon Clipping Algorithm (C++)

#include <iostream.h> #include <conio.h> #include <graphics.h> int xl,yl,xh,yh,poly[100],n; void left_clip(){ int temp[100],i,j=0,count=0,x1,y1,x2,y2; for(i=0;i<2*n;i+=2){ x1 = poly[i]; y1 = poly[i+1]; x2 = poly[i+2]; y2 = poly[i+3]; if(x1<xl && x2<xl){ //both points outside. Do not store any vertices }else if(x1>xl && x2>xl){ //both points inside. Store second vertex temp[j] = x2; temp[j+1] = y2; j+=2; count++; }else if(x1<xl && x2>xl){ //outside to inside. Store intersection n second … Continue reading Sutherland-Hodgeman Polygon Clipping Algorithm (C++)