Monday, 19 August 2013

/*
*********************************************************
Author:Satyabrata Jena
Program Created on Date:March-2007
*********************************************************

PROGRAM IN C TO CREATE GRAPHICAL CALCULATOR APPLICATION

NOTE ABOUT THIS : CALCULATOR PROGRAM IN C
----------------------------------------------------------------------
1)THIS CALCULATOR PROGRAM,
CAN PERFORM ARITHMETIC OPERATIONS ON ,ONLY NATURAL NUMBERS.

2)EACH TIME ,AFTER PERFORMING AN ARITHMETIC OPERATION ,
CLICK ON THE CLEAR BUTTON,
AND THEN PERFORM THE NEXT ARITHMETIC OPERATION.

3)YOU CAN ONLY PERFORM "BINARY ARITHMETIC OPERATION",USING THIS CALCULATOR.
FOR EXAMPLE YOU ARE ALLOWED TO ENTER 15*8 IN THE CALCULATOR,TO GET RESULT=120
BUT YOU ARE NOT ALLOWED TO ENTER A TERNARY OPERATION , LIKE 4*7*5.

SO TO CALCULATE THE VALUE OF 4*7*5 ,
FIRST YOU HAVE TO ENTER 4*7 AND GET THE OUTPUT,
AND THEN IN THE NEXT STEP ,MULTIPLY 5 WITH THE PREVIOUS RESULT.
*/

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void calculator_draw();
void showmouseptr();
void mousepos();
void show_pressed_button();
void initmouse();
char * convert(int );
int pows();
union REGS i,o;
char *ptr1[]={"1","2","3","4","5"};
char *ptr2[]={"6","7","8","9","0"};
char *ptr3[]={"+","-","*","/","="};
char data[50];

int width=50,click;
int global_x,dead;
/////////////////////////////////////////////////////////
int number1[20],num1_count;
int number2[20],num2_count;

int num1,power1;
int num2,power2;
int result;
int plus=0;
int line1,line2,line3;
int pl,mn,mul,divs;
////////////////////////////////////////////////////////

void main()
{
int gd=DETECT,gm;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
clearviewport();
calculator_draw();
initmouse();
showmouseptr();
show_pressed_button();
getch();
closegraph();

printf("num1=%d\tnum2=%d",num1,num2);
printf("\nnum1[0]=%d",number1[0]);
printf("\nnum2[0]=%d",number2[0]);
printf("\nnum1[1]=%d",number1[1]);
printf("\nnum2[1]=%d",number2[1]);
printf("\nnum1[2]=%d",number1[2]);
printf("\nnum2[2]=%d",number2[2]);
printf("line3=%d",line3);
printf("\nplus=%d",plus);
printf("\nnum1count=%d",num1_count);
printf("\nnum2count=%d",num2_count);
printf("\nresult=%d",result);
}

void calculator_draw()
{
int i,width=50,j,k;

//rectangle(0,0,639,479);
setfillstyle(SOLID_FILL,RED);
bar3d(60,80,560,400,20,20);

//dispay screen
setfillstyle(SOLID_FILL,BLUE);
bar3d(82,102,538,138,3,3);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);

//memory clear
setfillstyle(SOLID_FILL,MAGENTA);
bar3d(90,150,160,180,3,3);
outtextxy(100,150,"CLEAR");

setfillstyle(SOLID_FILL,DARKGRAY);
bar3d(460,150,540,180,3,3);
setcolor(YELLOW);
outtextxy(480,150,"QUIT");

settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
setfillstyle(SOLID_FILL,LIGHTGREEN);
setcolor(BLUE);
for(i=1;i<=5;i++)
{
bar3d(95*i,200,95*i+width,230,5,5);
outtextxy(95*i+20,200,ptr1[i-1]);
}
for(j=1;j<=5;j++)
{
bar3d(95*j,270,95*j+width,300,5,5);
outtextxy(95*j+20,270,ptr2[j-1]);
}
for(k=1;k<=5;k++)
{
bar3d(95*k,340,95*k+width,370,5,5);
outtextxy(95*k+20,340,ptr3[k-1]);
}
}

void showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
}

void mousepos(int *butt,int *mx,int *my)
{
i.x.ax=3;
int86(0x33,&i,&o);
*butt=o.x.bx;
*mx=o.x.cx;
*my=o.x.dx;
}

void show_pressed_button()
{
int button=0,mouse_x,mouse_y,i,j,k;
int n,digit;
int bot1,bot2;

num1=0;power1=0;
num2=0;power2=0;
result=0;
plus=555;
line1=0;line2=0;line3=5555;
num1_count=0;
num2_count=0;

setcolor(WHITE);

while(!kbhit())
{
mousepos(&button,&mouse_x,&mouse_y);
if(button==1&&mouse_x>=460&&mouse_x<=540&&mouse_y>=150&&mouse_y<=180)
{
exit(0);
}

mousepos(&button,&mouse_x,&mouse_y);
if(button==1&&mouse_x>=90&&mouse_x<=160&&mouse_y>=150&&mouse_y<=180)
{
for(i=1;i<50;i++)
{
data[i]='\0';
}

num1=0;power1=0;
num2=0;power2=0;
result=0;
plus=555;
line1=0;line2=0;line3=5555;
num1_count=0;
num2_count=0;
number1[0]=0;
number1[1]=0;
number1[2]=0;
number2[0]=0;
number2[1]=0;
number2[2]=0;
pl=0;mn=0;mul=0;divs=0;
click=0;
setviewport(84,104,536,136,1);
clearviewport();
}

for(i=1;i<=5;i=i+1)
{
setviewport(0,0,639,479,1);
button=0;
mousepos(&button,&mouse_x,&mouse_y);
if(button==1&&mouse_x>=95*i&&(mouse_y>=200)&&(mouse_x<=(95*i)+width)&&mouse_y<=230)
{
line1=i-1;
bot1=button;
setviewport(84,104,536,136,1);

outtextxy(click,0,ptr1[i-1]);
///////////////////////////////////////
if(plus==555){
number1[num1_count]=atoi(ptr1[i-1]);
num1_count=num1_count+1; }
///////////////////////////////////////

if(plus==1111)
{
number2[num2_count]=atoi(ptr1[i-1]);
num2_count=num2_count+1;
}

delay(200);
click=click+20;

}//end of if
}//end of for1

for(j=1;j<=5;j=j+1)
{
setviewport(0,0,639,479,1);
button=0;
mousepos(&button,&mouse_x,&mouse_y);
if(button==1&&mouse_x>=95*j&&(mouse_y>=270)&&(mouse_x<=(95*j)+width)&&mouse_y<=300)
{
bot2=button;
line2=j-1; //number's position or item position
setviewport(84,104,536,136,1);
outtextxy(click,0,ptr2[j-1]);
/////////////////////////////////////
if(plus==555)
{
number1[num1_count]=atoi(ptr2[j-1]);
num1_count=num1_count+1;
}
////////////////////////////////////////

if(plus==1111)
{
number2[num2_count]=atoi(ptr2[j-1]);
num2_count=num2_count+1;
}
delay(200);
click=click+20;
}
}//end of for

for(k=1;k<=5;k=k+1)
{
setviewport(0,0,639,479,1);
mousepos(&button,&mouse_x,&mouse_y);
if(button==1&&mouse_x>=95*k&&(mouse_y>=340)&&(mouse_x<=(95*k)+width)&&mouse_y<=370)
{
line3=k-1;
setviewport(84,104,536,136,1);
// clearviewport();
outtextxy(click,0,ptr3[k-1]);
delay(200);
click=click+20;
}

}//end of for3*/

if(line3==0 )
{
plus=1111;
pl=1;
power1=num1_count-1;
for(i=0;i<num1_count;i=i+1)
{
num1=num1+number1[i]*(pows(10,power1));
power1=power1-1;
}
line3=999;
}//end of if
///////////////////////////////////////////////////////////

if(line3==4 &&pl==1)
{
line3=999;

power2=num2_count-1;
for(i=0;i<num2_count;i=i+1)
{
num2=num2+number2[i]*(pows(10,power2));
power2=power2-1;
}

result=num1+num2;
pl=0;

setviewport(84,104,536,136,1);
clearviewport();
outtextxy(0,0,convert(result));
}//end of if
///////////////////////////////////////////MINUS
if(line3==1 )
{
plus=1111;
mn=1;
power1=num1_count-1;
for(i=0;i<num1_count;i=i+1)
{
num1=num1+number1[i]*(pows(10,power1));
power1=power1-1;
}
line3=999;
}
if(line3==4 &&mn==1)
{
line3=999;

power2=num2_count-1;
for(i=0;i<num2_count;i=i+1)
{
num2=num2+number2[i]*(pows(10,power2));
power2=power2-1;
}

result=num1-num2;
mn=0;

setviewport(84,104,536,136,1);
clearviewport();
if(result>=0)
outtextxy(0,0,convert(result));
else
{
result=result*(-1);
outtextxy(0,0,"-");
outtextxy(20,0,convert(result));
}
}//end of if

//////////////////////////////////////////////////////// MULTIPLY
if(line3==2 )
{
plus=1111;
mul=1;
power1=num1_count-1;
for(i=0;i<num1_count;i=i+1)
{
num1=num1+number1[i]*(pows(10,power1));
power1=power1-1;
}
line3=999;
}
if(line3==4 &&mul==1)
{
line3=999;

power2=num2_count-1;
for(i=0;i<num2_count;i=i+1)
{
num2=num2+number2[i]*(pows(10,power2));
power2=power2-1;
}

result=num1*num2;
mul=0;

setviewport(84,104,536,136,1);
clearviewport();
outtextxy(0,0,convert(result));
}//end of if
////////////////////////////////////////////////////////DIVISION
if(line3==3 )
{
plus=1111;
divs=1;
power1=num1_count-1;
for(i=0;i<num1_count;i=i+1)
{
num1=num1+number1[i]*(pows(10,power1));
power1=power1-1;
}
line3=999;
}
if(line3==4 &&divs==1)
{
line3=999;

power2=num2_count-1;
for(i=0;i<num2_count;i=i+1)
{
num2=num2+number2[i]*(pows(10,power2));
power2=power2-1;
}

result=num1/num2;
divs=0;

setviewport(84,104,536,136,1);
clearviewport();
outtextxy(0,0,convert(result));
}//end of if

}//end of while
}

void initmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
}
int pows(int num,int power)
{
int i,res;
if(power==0)
return 1;
res=1;
for(i=1;i<=power;i++)
{
res=res*num;
}
return res;
}

char * convert(int n)
{
int i,dig,k=0,length=0,count=0;
char set[]= {'0','1','2','3','4','5','6','7','8','9'};
char str[40];
while(n !=0)
{
dig=n%10;
count=count+1;
for(i=0;i<=9;i++)
{
if (dig==i)
{
str[k]=set[i];
k=k+1;
}
}
n=n/10;
}
for(i=0;i<count;i=i+1)
{
data[i]=str[count-i-1];
}
return data;
}

ANIMATED CALCULATOR
/*
*********************************************************
Author:Satyabrata Jena
Program Created on Date:March-2007
*********************************************************
PROGRAM IN C TO CREATE A FLYING BUTTERFLY
*/

#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
char *buff1,*buff2;
void main()
{
int gd=DETECT,gm;
void *buff;
int area1,area2,x,y;

initgraph(&gd,&gm,"c:\\tc\\bgi");

// FRONT IMAGE
ellipse(240,80,115,65,10,40);//body
///////////////
circle(240,40,10);
ellipse(215,40,15,100,20,40);
ellipse(265,40,85,165,20,40);
///////////////////////
ellipse(160,90,270,0,80,25); //left
ellipse(160,60,0,90,80,25);
ellipse(160,75,270,90,15,40);
ellipse(320,75,90,270,15,40);
////////////////////////////////////////////
ellipse(320,90,180,270,80,25); // right
ellipse(320,60,90,180,80,25);

setfillstyle(SOLID_FILL,YELLOW);
floodfill(240,40,WHITE);
setfillstyle(SOLID_FILL,BLUE);
floodfill(200,80,WHITE);
floodfill(290,60,WHITE);
setfillstyle(SOLID_FILL,BROWN);
floodfill(240,80,WHITE);
setfillstyle(SOLID_FILL,GREEN);
floodfill(240,110,WHITE);
//////////////////////////////////////////////
//Store image1
area1=imagesize(160,0,320,120);
buff1=malloc(area1);

getimage(160,0,320,120,buff1);
clearviewport();
//////////////////////////////////////////////
ellipse(240,80,120,60,10,40);
//////////////////
circle(240,40,10);
ellipse(215,40,15,100,20,30);
ellipse(265,40,85,165,20,30);
///////////////////////
ellipse(320,90,180,260,80,40); //1big y,right
ellipse(320,60,100,180,80,40);
ellipse(310,75,105,255,15,60);
////////////////////////////////////////////
ellipse(160,90,280,0,80,40); // left
ellipse(160,60,0,80,80,40);
ellipse(170,75,285,75,15,60);
setfillstyle(SOLID_FILL,YELLOW);
floodfill(240,40,WHITE);
setfillstyle(SOLID_FILL,BLUE);
floodfill(200,80,WHITE);
floodfill(290,60,WHITE);
setfillstyle(SOLID_FILL,BROWN);
floodfill(240,80,WHITE);
setfillstyle(SOLID_FILL,GREEN);
floodfill(240,110,WHITE);

//Store image2 (WINGS BEHIND)
area2=imagesize(160,0,320,140);
buff2=malloc(area2);
getimage(160,0,320,140,buff2);
clearviewport();

/////////////////////////////////////////////
x=220;y=475;
while(!kbhit())
{
if(y==25)
y=475;
putimage(x,y,buff1,COPY_PUT);
delay(30);
clearviewport();
putimage(x,y,buff2,COPY_PUT);
delay(30);
clearviewport();
y=y-15;
}
getch();
closegraph();
}
FLYING BUTTERFLY

Color changing ring

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy;
   int i;
   int stangle = 0, endangle = 360;
   int xradius = 100, yradius = 50;

   /* initialize graphics, local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)
   /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   /* terminate with an error code */
   }
   for(i=2;i<20;i++)
   {
   midx = 1000 / i;
   midy = 1000 / i;
   setcolor(i);

   /* draw ellipse */
   ellipse(midx, midy, stangle, endangle,
  xradius, yradius);
  delay(250);
  }
    /***************************************/
    for(i=20;i>2;i--)
    {
    midy = 1000 / i;
   midx = 1000 / i;
   setcolor(14);
   ellipse(midx, midy, stangle, endangle,
  xradius, yradius);
  delay(500);
   }
   setcolor(getmaxcolor());

   /* draw ellipse */
   ellipse(midx, midy, stangle, endangle,
  xradius, yradius);
   /***************************************/
   /* clean up */
   getch();
   closegraph();
   return 0;
}

Wednesday, 10 July 2013

Animated Ellipse image

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include<dos.h>
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int left, top, right, bottom;
   int midx,midy,i,stangle = 0,endangle = 360,xradius = 50,yradius = 50;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   left = getmaxx() / 2 - 50;
   top = getmaxy() / 2 - 50;
   right = getmaxx() / 2 + 50;
   bottom = getmaxy() / 2 + 50;

   /* draw a rectangle */
   rectangle(left,top,right,bottom);
/*************************************************************/
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)
/* an error occurred */
{
   printf("Graphics error: %s\n", grapherrormsg(errorcode));
   printf("Press any key to halt:");
   getch();
   exit(1);
/* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());


/* draw ellipse */
ellipse(midx, midy, stangle, endangle,
xradius, yradius);

stangle = 0,endangle = 360,xradius = 45,yradius = 45;
 for(i=0;i<=xradius;)
 {

ellipse(midx, midy, stangle, endangle,
xradius, yradius);
     xradius=xradius-5;
     yradius=yradius-5;
     delay(1000);
  }


/******************/
   /* clean up */
   getch();
   closegraph();
   return 0;
}

Sunday, 7 July 2013

KNOW NEW: Virtual reality gaming

KNOW NEW: Virtual reality gaming:                             " Oculus Rift " this kit now going to make possible for a new gaming environment. This device is the...

KNOW NEW: Gaming Tablet

KNOW NEW: Gaming Tablet:                                        Project Fiona   is the first generation gaming tablet.  This tablet built for hardcore gaming and...

Wednesday, 26 June 2013

ONLINE STORAGE

                          To good news to all them. most of  them know the google drive .it very useful to all online storage .to store the docs,excel,form,ppt,ext...........................
                          its available   only 5 GB but this week  onword to 15 GB  if you want more space to pay money and get storage space
                           Not only google provide this. Microsoft also provide this name is sky drive.it provide the 7GB  and more companies provide the facilities for example 
                       

                                            GOOGLE(15GB)
                                          MICROSOFT(SKY DRIVE)(7GB)
                                           DROPBOX(2GB)
and more of them provide this