Monday, October 15, 2007

I can give u alphabets if u give me DIGITS !!!




1 -- ONe 2 -- tWO 000 -- ZERo

Intro ::...

This program generates or gives alphabets for digits... For eg.. if u enter 200 it gets displayed as " Two hundred " Cool is'nt it.. I took great pain in bringing up this program... Try it out...


Source code :::...


/*PROGRAM THAT GIVES NUMBER IN WORDS*/

#include stdio.h
#include conio.h
#include string.h

char t[40]=" ",u[40]=" ",v[40]=" ",w[40]=" ",y[40]=" ";
void d1(char [9][20],long int );
void d2(char [9][20],char [18][20],long int );
int d3(char [9][20],char [18][20],long int ,char [6],char [3][10]);
void d4(char [9][20],char [18][20],long int ,char [6],char [3][10],int ,int );
void ch(char [9][20],char [18][20],long int ,char [6],char [3][10],int ,int );

void main()
{
int i=0,x,k=0;
long int n,num,z,j;
char a[9][20]={" one"," two"," three"," four"," five"," six"," seven"," eight"," nine"},b[18][20]={" ten"," eleven"," twelve"," thirteen"," fourteen"," fifteen"," sixteen"," seventeen"," eighteeen"," nineteen","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
char c[3][10]={" hundred"," thousand"," lakh"},an[6]={" and "};
clrscr();
printf("\n\n\n\n\n\n\n\n\n\ENTER THE NUMBER\n\n\t");
scanf("%ld",&n);
num=n;
while(n!=0)
{
n=n/10;
i++;
}
k=i;
switch(i)
{
case 0:
{
printf("zero\n");
break;
}
case 1:
{
d1(a,num);
puts(t);
break;
}
case 2:
{
d2(a,b,num);
puts(t);
break;
}
case 3:
{
x=d3(a,b,num,an,c);
puts(a[x-1]);
break;
}
case 4:
case 5:
{
d4(a,b,num,an,c,k,x);
puts(u);
break;
}
case 6:
case 7:
case 8:
{
z=num;
num=z/100000;
j=num;
ch(a,b,num,an,c,j,x);
strcat(t,c[2]);
strcpy(y,t);
num=z%100000;
if(num==0)
{
if(i==1)
puts(y);
else
{
strcat(t,"s");
puts(t);
}
}
else
{
j=num;
ch(a,b,num,an,c,j,x);
strcat(y,t);
puts(y);
}
break;
}
}
getch();
}

void d1(char a[9][20],long int num)
{
strcpy(t,v);
num%=10;
strcpy(t,a[num-1]);
}

void d2(char a[9][20],char b[18][20],long int num)
{
int i=0,j,k;
strcpy(t,v);
if(num/10==1)
{
num%=10;
strcpy(t,b[num]);
}
else
{
if(num%10==0)
{
num/=10;
strcpy(t,b[num+8]);
}
else
{ while(i<2)
{
i++;
k=num%10;
if(i=1)
j=k;
else
{
strcpy(w,v);
strcat(w,b[k+8]);
strcat(w,a[j-1]);
strcpy(t,w);
}
num/=10;
}
}
}
}

int d3(char a[9][20],char b[18][20],long int num,char an[6],char c[3][10])
{
int i=0;
i=num/100;
strcpy(t,v);
if(num%100==0)
strcat(a[i-1],c[0]);
else
{
num%=100;
if((num/10)%10==0)
d1(a,num);
else d2(a,b,num);
strcat(a[i-1],c[0]);
strcat(a[i-1],an);
strcat(a[i-1],t);
}
return(i);
}

void d4(char a[9][20],char b[18][20],long int num,char an[6],char c[3][10],int k,int x)
{
int j=0;
long int i,n;
strcpy(u,v);
i=num/1000;
if(num%1000==0)
{
if(k==5)
{
n=num;
num=i;
d2(a,b,num);
num=n;
strcat(t,c[1]);
strcat(u,t);
}
else
{
strcat(a[i-1],c[1]);
strcat(u,a[i-1]);
}
}
else
{
if(k==5)
{
n=num;
num=i;
d2(a,b,num);
num=n;
strcat(u,t);
}
else
strcat(u,a[i-1]);
strcat(u,c[1]);
num%=1000;
n=num;
j=0;
while(n!=0)
{
n/=10;
j++;
}
if(j==1)
{
d1(a,num);
strcat(u,an);
strcat(u,t);
}
else if(j==2)
{
d2(a,b,num);
strcat(u,an);
strcat(u,t);
}
else
{
x=d3(a,b,num,an,c);
strcat(u,a[x-1]);
}
}
}

void ch(char a[9][20],char b[18][20],long int num,char an[6],char c[3[10],int j,int x)
{
int i=0,k;
strcpy(t,v);
while(j!=0)
{
j/=10;
i++;
}
if(i==1)
d1(a,num);
else if(i==2)
d2(a,b,num);
else if(i==3)
{
x=d3(a,b,num,an,c);
strcpy(t,a[x-1]);
}
else
{
k=i;
d4(a,b,num,an,c,k,x);
strcpy(t,u);
}
}


Merits ::...

* This program does not contain any exceptional cases..
* This program is valid upto eight digits and not more..

Look out ::...

This program can be run on anyother normal C compilers... Your comments are always welcomed....

Saturday, September 29, 2007

Do u have calendar for the year 3000... I have....



FUTURE IS OURS


Intro ::...


This program gives u the entire years calendar for any year strarting from year 0001 to year 5000 to the best of my knowledge... I hope this one of the rarely found and one among the valuable that I have tried out...


Source Code :::....

/*PROGRAM TO PRINT ANY ACADEMIC YEARS CALENDAR*/
#include stdio.h
#include conio.h

FILE *fp;
void ca(int);
int da(int ,int);

void main()
{
int z,i,k=0,m1=1,m2=1,y1=1,y2,j;
char a[7]={'S','M','T','W','T','F','S'};
char b[12][10]={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","
JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER",
"NOVEMBER","DECEMBER"};
long int d=0,y=0;
fp=fopen("calendar.txt","w+");
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\tENTER THE YEAR\n\n\t");
scanf("%d",&y2);
fprintf(fp,"\tCALENDAR - %d\n\n\n",y2);
while(m1=12&&y1!=y2)
{
m1=1;
y1++;
}
else
m1++;
}
d+=y;
i=d%7;
while(m2<=12)
{
fprintf(fp,"\t\t%s\n\n\n",b[k]);
k++;
for(j=0;j<7;j++)
{
fprintf(fp,"%c\t",a[j]);
}
fprintf(fp,"\n");
ca(i);
z=da(m2,y2);
for(j=1;j<=z;j++)
{
if(i<=6)
{
fprintf(fp,"%d\t",j);
i++;
}
else
{
fprintf(fp,"\n%d\t",j); i=1;
}
}
fprintf(fp,"\n\n\n\n");
m2++;
}
fclose(fp);
getch();
}
void ca(int i)
{
switch(i)
{
case 0:
break;
case 1:
fprintf(fp,"\n\t");
break;
case 2:
fprintf(fp,"\n\t\t");
break;
case 3:
fprintf(fp,"\n\t\t\t");
break;
case 4:
fprintf(fp,"\n\t\t\t\t");
break;
case 5:
fprintf(fp,"\n\t\t\t\t\t");
break;
case 6:
fprintf(fp,"\n\t\t\t\t\t\t");
break;
}
}
int da(int m2,int y2)
{
int x=0;
if(m2<=7&&m2!=2)
{
if(m2%2==0)
x=30;
else
x=31;
}
else if(m2>7)
{
if(m2%2==0)
x=31;
else
x=30;
}
else
{
if(y2%4==0)
x=29;
else
x=28;
}
return(x);
}


Merits ::...

*This program gives the academic calendar for any years calendar
* Includes leap year
*Very helpful in the field of astrology
*Alignment is similar to that u see in your normal wall calendar

Look out ::...

This program can be run in any C compilers... Important thing is that the output will only be displayed in a notepad file outside the compiler... This is because while displaying the entire year's calendar only a last few months are visible in DOS PROMPT after execution.... So in case of notepad file entire years calendar can be displayed....

Your comments are always welcomed....




U may know ur date of birth but ur day of birth !!!



DATE ----------->>> DAY
Intro ::..


This program is used to find the day of a any given date... This may be your birthday or the day u met your first spouse or anything else.... This program is created with the last program as a base...


Source Code ::...


/*PROGRAM TO FIND THE DAY OF ANY DATE*/

#include stdio.h
#include conio.h
void main()
{
int x,i,d1=1,d2,m1=1,m2,y1=1,y2;
long int d=0,y=0;
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\tENTER THE DATE\n\n\t");
scanf("%d%d%d",&d2,&m2,&y2);
if(m2>12d2>31(m2==2&&((y2%4==0&&d2>29)(y2%4!=0&&d2>28))))
printf("\n\n\tInvalid date");
else
{
if(m1==m2&&y1==y2)
d=d2-d1;
else
{
d=31-d1;
d+=d2;
}
m1++;
while(m1=12&&y1!=y2)
{
m1=1;
y1++;
}
else
m1++;
}
d+=y;
i=d%7;
printf("\n\n\tThe day corresponding to the given date is\n\n\t\t");
switch(i)
{
case 6:
printf("SATURDAY");
break;
case 0:
printf("SUNDAY");
break;
case 1:
printf("MONDAY");
break;
case 2:
printf("TUESDAY");
break;
case 3:
printf("WEDNESDAY");
break;
case 4:
printf("THURSDAY");
break;
case 5:
printf("FRIDAY");
break;
}
}
getch();
}


Merits ::..


* This program too has no exceptional cases...U can know even the day when Buddha was born if u know the date....



Look out ::...


This program can be run on any normal C compilers...


Want to know your age in days....



DATE - DATE ===== ?????
Intro ::..


This program is built to find the difference between of days between the two given dates... The C language is used for its construction... This is the first program that i have tried out with a great grit... I thank my teacher since she is behind its thought...


Source Code ::..



/*PROGRAM TO FIND THE NUMBER DAYS BETWEEN TWO DATES*/

#include stdio.h
void main()

{
int x=0,d1,d2,m1,m2,y1,y2,t;
long int d=0,y=0;
clrscr();
printf("\n\n\n\n\n\tENTER THE FIRST DATE\n\n\t");
scanf("%d%d%d",&d1,&m1,&y1);
printf("\n\n\n\n\nENTER THE SECOND DATE\n\n\t");
scanf("%d%d%d",&d2,&m2,&y2);
if(y1>y2)
{
t=y1;
y1=y2;
y2=t;
t=m1;
m1=m2;
m2=t;
t=d1;
d1=d2;
d2=t;
}
if(y1==y2&&m1>m2)
{
t=m1;
m1=m2;
m2=t;
t=d1;
d1=d2;
d2=t;
}
if(m1<=7&&m1!=2)
{
if(m1%2==0)
x=30;
else
x=31;
}
else if(m1>7)
{
if(m1%2==0)
x=31;
else
x=30;
}
else
{
if(y%4==0)
x=29;
else
x=28;
}
if(m1==m2&&y1==y2)
d=d2-d1;
else
{
d=x-d1;
d+=d2;
}
m1++;
while(m1=12&&y1!=y2)
{
m1=1;
y1++;
}
else
m1++;
}
d+=y;
printf("\nthe no of days between the two\ngiven dates are %ld\n",d);
getch();
}


Merits ::...


* I have tried out for almost all possible inputs and there are no exceptional cases...


Look out ::..


By copying this code and placing it in your any of the C compilers you can exectute the program...