Wednesday 12 September 2012

Stop watch

#include<iostream>
#include<conio.h>
//#include<stdlib.h>
//#include<stdio.h>
//#include<math.h>
//#include<dos.h>
//#include<string.h>
using namespace std;
void main()
{
//clrscr();


for(int i=0;i<23;i++)

{

for(int j=0;j<59;j++)

{
 
for(int k=0;k<59;k++)
 
{

  
for(int m=0;m<60;m++)
  
{
   cout<<"\n\n\n\n\n\t\t\t\t"<<i<<" :"<<j<<" :"<<k<<" :"<<m;

   
//delay(15);
 
//clrscr();
  
}
 
 
}

}

}



//getch();
}

table print

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b=1,limit;
cout<<"Enter the number= ";
cin>>a;
cout<<"\nEnter the limit= ";
cin>>limit;
while(b<=limit)
{
  cout<<"\n"<<a<<" * "<<b<<" = "<<a*b<<"\n";
  b=b++;
  }
  getch();
  }

calculate height and widht of rectangular

#include<iostream.h>
using namespace std;

class rect{
int left;
int right;
int top;
int bottom;

public:

rect(){
left=0;
right=0;
top=0;
bottom=0;
}

void widht(int w,int x){
int wid;
left=w;
right=x;
wid=right-left;
cout<<wid;
}

void height(int y,int z){
int hei;
top=y;
bottom=z;
hei=bottom-top;
cout<<hei;
}
};
void main(){
clrscr();
rect s1;
int w,x,y,z;
cout<<"\nenter your left side :";
cin>>w;
cout<<"\nenter your right side :";
cin>>x;
cout<<"\nenter your top side :";
cin>>y;
cout<<"\nenter you bootom side :";
cin>>z;

cout<<"\n width :";
s1.widht(w,x);

cout<<"\n height :";
s1.height(y,z);


}

guess a number game

#include <iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
int number,i=1,true;
srand(time(0));
true=1+rand()%40;
while(i==1)
{
cout<<"\nEnter the number between (1_40)= ";

cin>>number;
if(number==true)
{
cout<<"\nYou won the game";
break;
}
if(number!=true)
{
cout<<"\nYou don't won the game";
if(number>true)
{
cout<<"\nThe number you entered is greater than the true number";
}
else
cout<<"\nThe number you entered is lesser than the true number";
continue;
}
}
getch();

}

Palindrom

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x,a,b,c,d,e,f,g,h;
cout<<"Enter the 5 digit integer=";
cin>>x;
a=x/10000;
b=x%10000;
c=b/1000;
d=b%1000;
e=d/100;
f=d%100;
g=f/10;
h=f%10;
if(a==h&&c==g)
cout<<"the number is palindrome";
else
cout<<"not a palindrome";
getch();
}

Multiple or not

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int a,b;
 cout<<"Enter the first integar:";
 cin>>a;
 cout<<"\nEnter the second integar:";
 cin>>b;
 if(a%b==0)
 cout<<"\n"<<a<<" is a multiple of "<<b;
 else
 cout<<"\n"<<a<<" is not the miltiple of "<<b;
 getch();
 }

Histogram

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e,f,i=1;
cout<<"Enter the 5 digit Integer=";
cin>>a>>b>>c>>d>>e;
while(i<=a)
{
 cout<<"*";
 i++;
 }
 i=1;
 cout<<endl;
 while(i<=b)
 {
  cout<<"*";
  i++;
  }
  cout<<endl;
  i=1;
  while(i<=c)
  {
  cout<<"*";
  i++;
  }
  cout<<endl;
  i=1;
  while(i<=d)
  {
  cout<<"*";
  i++;
  }
  cout<<endl;
  i=1;
  while(i<=e)
  {
  cout<<"*";
  i++;
  }

  getch();
  }