C++ version of the song!!
PS: Since the blog editor doesn't accept the special characters '<' & '>' (or I haven't figured out how to make them accepted) which are very frequently used in C++, I have replaced them (using Microsoft Word).
'<' has been replaced by '~' and '>' has been replaced by '?'. So to run the program, first replace the characters back to original.
#include~iostream.h?
#include~conio.h?
#include~dos.h?
int main(void)
{
float sa=261.63, re=293.66, ga=329.63, ma=341.33, pa=392, dha=440, ni=493.88, sa1=523.25, re1=587.33, ga1=659.26, ma1=698.46;
float ko_ni=466.16;
for(int i=0;i~2;i++)
{ sound(sa1);
delay(600);
nosound();
sound(ni);
delay(120);
nosound();
sound(sa1);
delay(600);
nosound();
sound(ni);
delay(120);
nosound();
sound(sa1);
delay(600);
nosound();
sound(ni);
delay(120);
nosound();
sound(sa1);
delay(150);
nosound();
sound(ga1);
delay(150);
nosound();
sound(re1);
delay(150);
nosound();
sound(sa1);
delay(150);
nosound();
sound(ni);
delay(600);
nosound();
sound(dha);
delay(110);
nosound();
sound(ni);
delay(600);
nosound();
sound(dha);
delay(110);
nosound();
sound(ni);
delay(1250);
nosound();
}
sound(pa);
delay(300);
nosound();
sound(dha);
delay(300);
nosound();
sound(sa1);
delay(150);
nosound();
sound(dha);
delay(1250);
nosound();
sound(ma);
delay(300);
nosound();
sound(pa);
delay(300);
nosound();
sound(dha);
delay(150);
nosound();
sound(pa);
delay(1250);
nosound();
sound(pa);
delay(300);
nosound();
sound(dha);
delay(300);
nosound();
sound(sa1);
delay(150);
nosound();
sound(dha);
delay(1250);
nosound();
sound(ma);
delay(250);
nosound();
sound(ni);
delay(100);
nosound();
sound(ko_ni);
delay(750);
nosound();
sound(dha);
delay(125);
nosound();
sound(pa);
delay(1000);
nosound();
}
Tuesday, July 13, 2010
Sunday, July 11, 2010
Slot Machine
A miniature version of slot machine. Just the rolling part.
PS: Since the blog editor doesn't accept the special characters '<' & '>' (or I haven't figured out how to make them accepted) which are very frequently used in C++, I have replaced them (using Microsoft Word).
'<' has been replaced by '~' and '>' has been replaced by '?'. So to run the program first replace the characters back to original.
#include~iostream.h?
#include~conio.h?
void main()
{
clrscr();
int a[3]={1009,991,1488},m=0,row=1,col=1,l=0;
while (m~3)
{
for(double i=99999;i?0;i--)
{
gotoxy(row,col);
cout~~i;
for(double j=0;j~9999;j++);
if(i==85000)
break;
}
gotoxy(row,col);
cout~~a[l]~~" "~~endl;
col++;
m++;l++;
}
getch();
}
PS: Since the blog editor doesn't accept the special characters '<' & '>' (or I haven't figured out how to make them accepted) which are very frequently used in C++, I have replaced them (using Microsoft Word).
'<' has been replaced by '~' and '>' has been replaced by '?'. So to run the program first replace the characters back to original.
#include~iostream.h?
#include~conio.h?
void main()
{
clrscr();
int a[3]={1009,991,1488},m=0,row=1,col=1,l=0;
while (m~3)
{
for(double i=99999;i?0;i--)
{
gotoxy(row,col);
cout~~i;
for(double j=0;j~9999;j++);
if(i==85000)
break;
}
gotoxy(row,col);
cout~~a[l]~~" "~~endl;
col++;
m++;l++;
}
getch();
}
Ribbons

PS: Since the blog editor doesn't accept the special characters '<' & '>' (or I haven't figured out how to make them accepted) which are very frequently used in C++, I have replaced them (using Microsoft Word).
'<' has been replaced by '~' and '>' has been replaced by '?'. So to run the program first replace the characters back to original.
This program may not work on various computers due to different dimension.
Didn't really work out the way I wanted it to.
But deserves a look!
There are some minor problems with this one.
The cursor can be navigated using the keys W,A,S,D. But in the beginning of the program, the nagigation is sort of stuck.
Here is the solution: Press 'S' 3-4 times and then press'D' 3-4 times. This will make the navigation part work freely.
Then move the cursor anywhere on the screen and press 'ENTER'. Whoa!
The program won't end by pressing Esc. So press 'Ctrl + Break' 2-3 times.
#include~iostream.h?
#include~conio.h?
#include~process.h?
void main()
{
clrscr();
int t=0;
int x=0,y=0; //Coordinates.
int a=42; //Will tell the direction of ball. Left upper corner is position 1. Here 42 means, ball goes from corner # 4 to corner # 2.
int l=2; //The # of Wall : Upper frame is wall # 1.
int len=79, br=49; //Dimensions of Length and Breadth.
long speed=2999999; //Defines how fast the ball moves.
char ch; //Choice for W,A,S,D.
char cha='*'; //Character which will represent the ball.
char cha2='*';
while(x?=0 && y?=0)
{
ch=getch();
if(ch=='w')
gotoxy(x,y=y-1);
else if(ch=='a')
gotoxy(x=x-1,y);
else if(ch=='s')
gotoxy(x,y=y+1);
else if(ch=='d')
gotoxy(x=x+1,y);
else if(ch!='w' || ch!='a' || ch!='s' || ch!='d')
break;
}
while(x~=len && y~=br)
{
//clrscr();
if(y==br && x~len)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(++x,--y);
l=3;
}
if(y==0 && x~len)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(--x,++y);
l=1;
}
if(x==0 && y~br)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(++x,++y);
l=2;
}
if(x==len && y~br)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(--x,--y);
l=4;
}
while(x~len && x?0 && y?0 && y~br && l==2 && a==42)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(++x,++y);
t=1;
}
if(t==1)
a=13;
while(x~len && x?0 && y?0 && y~br && l==2 && a==31)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(++x,--y);
t=2;
}
if(t==2)
a=24;
while(x~len && x?0 && y?0 && y~br && l==3 && a==13)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(++x,--y);
t=3;
}
if(t==3)
a=24;
while(x~len && x?0 && y?0 && y~br && l==3 && a==42)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(--x,--y);
t=4;
}
if(t==4)
a=31;
while(x~len && x?0 && y?0 && y~br && l==4 && a==24)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(--x,--y);
t=5;
}
if(t==5)
a=31;
while(x~len && x?0 && y?0 && y~br && l==4 && a==13)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(--x,++y);
t=6;
}
if(t==6)
a=42;
while(x~len && x?0 && y?0 && y~br && l==1 && a==31)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(--x,++y);
t=7;
}
if(t==7)
a=42;
while(x~len && x?0 && y?0 && y~br && l==1 && a==24)
{
gotoxy(x,y);
cout~~cha;
gotoxy(x,y);
for(long j=1;j~speed;j++);
cout~~cha2;
gotoxy(++x,++y);
t=8;
}
if(t==8)
a=13;
}
getch();
}
Saturday, July 10, 2010
Hour Glass

Hourglass animation in C++.
Truly amazing!
Created by Amit Garg (who is not interested in publicizing himself) and myself in 2008.
PS: Since the blog editor doesn't accept the special characters '<' & '>' (or I haven't figured out how to make them accepted) which are very frequently used in C++, I have replaced them (using Microsoft Word).
'<' has been replaced by '~' and '>' has been replaced by '?'. So to run the program first replace the characters back to original.
#include~iostream.h?
#include~conio.h?
void main()
{
clrscr();
float i,j,k,l;
int a,b,c,d,e,f,g=0,a1,b1,c1,d1,e1,f1=12,g1=0;
gotoxy(30,13);
cout~~"An Ankit-Amit Creation";
gotoxy(1,1);
for(long t=0;t~=999999999;t++);
cout~~" ";
for(i=1 ;i~=25;++i)
cout~~"*";
cout~~endl;
for(i=10;i?=0;--i)
{
for(j=12;j?=i;j--)
cout~~" ";
for(k=i;k?=0;k=k -0.5)
cout~~".";
cout~~endl;
}
for(i=10;i?=0;--i)
{
for(j=0;j ~=i+2;j++)
cout~~" ";
for(k=10;k?=i;k=k-0.5)
cout~~" ";
cout~~endl;
}
cout~~" ";
for(i=1;i~=25;++i)
cout~~"*";
j=2;k=3;
for(i=1;i~=11;i++)
{
gotoxy(k++,j++ );
cout~~"*";
}
gotoxy(13,13);
cout~~"*";
j=13;k=13;
for(i=0;i~= 10;i++)
{
gotoxy(k--,j++ );
cout~~"*";
}
j=25;k=2;
for(i=1;i~=11;i++)
{
gotoxy(j--,k++);
cout~~"*";
}
j=15;k=13;
for(i=1;i~=11;i++)
{
gotoxy(j++,k++ );
cout~~"*";
}
for(long ll=1;ll~199999999;++ll);
for(i=1;i~12;++i)
{
e1=14;
for(int kk=1;kk~=12&&i==1;++kk)
{
gotoxy(e1,f1++);
cout~~".";
for(long jj=1;jj~=29999999;++jj);
}
}
for(i=1;i~12;++i)
{
for(long ll=1;ll~29999999;++ll);
g++; g1++;
a=14-i; a1=14-i;
c=14+i; c1=14+i;
b=2; b1=23;
d=2; d1=23;
e=14;
f=2;
for(j=i;j?=1;j--)
{
gotoxy(e,f++);
cout~~" ";
if(g!=11)
{
gotoxy(a++,b++);
cout~~" ";
gotoxy( c--,d++);
cout~~" ";
gotoxy(a1 ++,b1--);
cout~~".";
gotoxy( c1--,d1--);
cout~~".";
}
for(long ll=1;ll~29999999;++ll);
}
}
getch();
}
Subscribe to:
Posts (Atom)