Boolean Island !

Entries categorized as ‘C’

Any year Calendar

October 25, 2007 · No Comments

Here is the C code for Any year Calendar its v1.0.Just copy the code and past and then use Turbo C to compile it.

CODE:

#include “stdio.h”
#include “conio.h”

int d[12][5][7]={0};

//for print

void pr(char *m,int a)
{int l,j,i;
char day[21]={”sa su mo tu we th fr”};

printf(”%s”,m);
for(l=0;l<3;l++)
printf(” %s “,day);
printf(”\n\n”);
for(i=0;i<5;i++)
{ for(j=0;j<7;j++)
printf(”%3d”,d[a+0][i][j]);
if(j%7==0)
{printf(” “);
for(j=0;j<7;j++)
printf(”%3d”,d[a+1][i][j]);
if(j%7==0)
{printf(” “);
for(j=0;j<7;j++)
printf(”%3d”,d[a+2][i][j]);}

printf(”\n\n”);}
}
printf(”\n\n”);getch();
}
//————————————————————————–

void main()
{
int i,xl,k,l,j,a,m,x,y,z,g,c,y1=0,M=0,b=0,Y,C,flag;

char *m1={”\tJANUARY\t\t\tFEBRUARY\t\tMARCH\n\n”};
char *m2={”\tAPRIL\t\t\t MAY\t\t\t JUN\n\n”};
char *m3={”\tJULY\t\t\tAUGUST\t\t\tSEPTEMBER\n\n”};
char *m4={”\tOCTOBER\t\t\tNOVEMBER\t\tDECEMBER\n\n”};

clrscr();
printf(”Please Enter Year:”);
scanf(”%d”,&y1);

Y=(y1-1)%100;
C=(y1-1)/100;
x=(2.6*11-.02)+1+Y+(Y/4)+(C/4)-2*C;
x=x%7;
x=(x+1)%7;

xl=0;
flag=0;

for(k=0;k<12;k++)
{
a=1;
for(j=x;j<7;j++)
d[k][0][j]=a++;

if(flag==1)
d[k][0][0]=0;

flag=0;
if((k==0)||(k==2)||(k==4)||(k==6)||(k==7)||(k==9)||(k==11))
{
if(x==5)
{d[k][0][0]=31;flag=1;}
if(x==6)
{
d[k][0][0]=30;d[k][0][1]=31;flag=1;
}
}
else if( (x==6) && ((k==3)||(k==5)||(k==8)||(k==10)) )
{ d[k][0][0]=30;flag=1;}

for(i=1;i<4;i++)
for(j=0;j<7;j++)
d[k][i][j]=a++;

if((k==0)||(k==2)||(k==4)||(k==6)||(k==7)||(k==9)||(k==11))
b=31;
else if((k==3)||(k==5)||(k==8)||(k==10))
b=30;
else if(k==1)
{if((y1%4==0)||((y1%100!=0)&&(y1%400==0)))
b=29;
else
b=28;
}

for(j=0;a<=b;j++)
d[k][4][j]=a++;

x=j%7;

}

getch();
clrscr();
for(i=0;i<33;i++)
printf(” “);
printf(”%d”,y1);
for(i=37;i<80;i++)
printf(” “);
printf(”\n\n”);

pr(m1,0);
pr(m2,3);
pr(m3,6);
pr(m4,9);

getch();
}

Categories: C
Tagged: , ,

Fun with Turbo C

September 26, 2007 · No Comments

Here is a program which show sin,cos,tan graph . Just copy and past in .c or .cpp file and compile and see :)

/**********************************************
* Fun with C. /
* Sin,cos,tan grapth in Turbo C. /
* Aughtor:Raquibul Islam /
* Email:rana_cse_05@yahoo.com /
* http://ranacse05.blogspot.com /
* http://ranacse05.wordpress.com /
* http://www.ranacse05.tk /
***********************************************/

#include “stdio.h”
#include “Math.h”
#include “graphics.h”

int main()
{
double i,cone,redian=22.0/(7.0*180.0);

int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver,&gmode,”f:\\tc\\bgi”);//Here is the path of the egevge file.

//—2 lines for axais.
line(50,50,50,400);
line(50,220,550,220);

for(i=50.0,cone=0;i<550.0;i=i+.1,cone=cone+.1)
{
putpixel(i,220-((sin(cone*redian))*50),2); //for sine
putpixel(i,220-((cos(cone*redian))*50),3); //for cos
putpixel(i,220-((tan(cone*redian))*50),5); //for tan
delay(3);
}
delay(2000);
return 0;
}

Categories: C · programming
Tagged: , ,