Saturday, 20 April 2013

How To Make A Clock By Using C++ And OOPS Language


How To Make A Clock By Using C++ And OOPS Language
Copy This Given text And Save With the name of Clock.cpp In A Notepad File And Compile By this Your C Complier

#include<stdio.h>
#include<process.h>
#include<iostream.h>
#include<dos.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
void draw()
{
setbkcolor(0);
setlinestyle(0,0,0);
setcolor(9);
circle(320,240,3);
setcolor(11);
setfillstyle(6,13);
circle(320,240,150);
circle(320,240,165);
floodfill(156,242,11);
settextstyle(2,0,5);
setcolor(14);
outtextxy(314,98,"12");
outtextxy(384,114,"1");
outtextxy(434,163,"2");
outtextxy(454,230,"3");
outtextxy(317,369,"6");
outtextxy(177,230,"9");
outtextxy(436,300,"4");
outtextxy(195,302,"8");
outtextxy(195,163,"10");
outtextxy(244,112,"11");
outtextxy(388,353,"5");
outtextxy(248,353,"7");
}
main()
{

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

draw();
//line(320,240,320,130);
//line(320,240,320,150);
//getch();
float s;
float df;
//s=282*M_PI/180;
//float angle=4.712389;
//float an=4.712389;
float anf=4.712389;

//float angle=0;
int x,y;
int q,w;
int ta,d;

float as;
as=6*M_PI/180;

int c2=0;
int count=0;
struct  time t;
gettime(&t);
float angle=4.712389+t.ti_sec*.1047198;
float an=4.712389+t.ti_min*.1047198;
while(!kbhit())
{
draw();
gettime(&t);
gotoxy(5,5);
angle=4.712389+t.ti_sec*.1047198;
an=4.712389+t.ti_min*.1047198;
anf=4.712389+t.ti_hour*5*.1047198 ;
if(t.ti_min>=12&&t.ti_min<24)
{
anf=anf+2*.1047198;
}
if(t.ti_min>=24&&t.ti_min<36)
{
anf=anf+(3*.1047198);
}
if(t.ti_min>=36&&t.ti_min<48)
{
anf=anf+(4*.1047198);
}
if(t.ti_min>=48&&t.ti_min<60)
{
anf=anf+(5*.1047198);
}


gotoxy(2,2);
printf("The current time is: %d: %d: %d", t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);

cout<<"   ";
setlinestyle(0,0,0);
setcolor(0);
line(320,240,x,y);
line(320,240,q,w);
line(320,240,ta,d);

x=320+140*cos(angle);
y=240+140*sin(angle);
q=320+122*cos(an);
w=240+122*sin(an);
ta=320+86*cos(anf);
d=240+86*sin(anf);
setcolor(10);
setlinestyle(0,0,0);
line(320,240,x,y);
setlinestyle(0,0,2);
setcolor(9);
line(320,240,q,w);
setlinestyle(0,0,3);
setcolor(4);
line(320,240,ta,d);
angle+=.1047198;
delay(1000);
count++;

/*if(c2==12)
{
setlinestyle(0,0,3);
c2=0;
anf+=.1047198;
} */
setcolor(count);
outtextxy(370,440,"MADE BY :- Sunil Kumar Dheendhwal");
outtextxy(390,460,"BOSS OF PROGRAMMING");

}


getch();
}

Sunday, 14 April 2013

How To Start Programming With C++ And OOPS



when You Installed Turbo C and C++ after that you want to know how to start programming

Here I will tell you that
Open DosBox That Is On Your Desktop(As A shortcut of DosBox)
when It open Click On "File" after that on "new"
now you seen a blue page
click on it
write the first is headerfils
header files are
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<graphics.h>
//etc..........
//after that you need to write any message but before that
//you need to write the main body so write
main()
{
//now you start your programme's body
//here you can write your msg
//for writing messege neet to put the command and the command is
//"cout" now see how can use this command
cout<<"My First C Programme";
getch();
}

now your programme is ready

see your fully programme that will show Your message"My First C Programme" is

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<graphics.h>
main()
{
cout<<"My First C Programme";
getch();
}

and most importent is this before run this save with .cpp name
like that myfirst.cpp of no1.cpp or myprog.cpp
but always have .c exetensen

Any More Info Click on Any Other post
any Help Comment here

Monday, 8 April 2013

Real And Img Part In C++ And OOPS



#include<iostream.h>#include<conio.h>
class complex
{
float x,y;
public:
complex()
{}
complex (float real, float imag)
{
x=real;
y=imag;
}
complex operator +(complex c)
{
complex temp;
temp.x=x+c.x;
temp.y=y+c.y;
return(temp);
}
void display()
{
cout<<x<<"+i"<<y;
}
};
void main()
{
clrscr();

complex  c1(1.2,3.4);
complex c2(5.6,7.8);
complex c3;
c3=c1+c2;
cout<<"\nC1:-";
c1.display();
cout<<"\nC2:-";
c2.display();
cout<<"\nC3:-";
c3.display();
getch();
}

Static Programme in C++




#include<iostream.h>
#include<conio.h>
class test
{
int code;
static int count;
public:
void setcode()
{
code=++count;
}
void showcode()
{
cout<<"\n Code:-"<<code<<endl;
}
static void showcount()
{
cout<<"\n Count:-"<<count<<endl;
}
};
int test :: count;
void main()
{
clrscr();
test t1,t2;
test::showcount();
t1.setcode();
t1.showcode();
test::showcount();
t2.setcode();
t2.showcode();
test::showcount();
t1.showcode();
t2.showcode();
getch();
};


How To make a table in C++




#include<iostream.h>
#include<conio.h>
void main()
{
int a,i,n;
clrscr();
cout<<"Enter the no:-";
cin>>a;
cout<<"table of n is:-"<<a;
for(i=1;i<=10;i++)
{
n=a*i;
cout<<"\n"<<n;
}
getch();
}

/*Output:-
Enter the no:-9
table of n is:-9
9
18
27
36
45
54
63
72
81
90*/




Marquee In C++ Or Marquee In OOPS Or Running Line In C++






#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm;
int i;
initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(1,0,2);
settextjustify(1,1);
for(i=0;i<getmaxx();i++)
{
setcolor(i);
outtextxy(getmaxx()-i,getmaxy()/20,"SUNIL KUMAR DHEENDHWAL");
sound(((i+5)%10)*1000);
delay(20);
setcolor(getbkcolor());
outtextxy(getmaxx()-i,getmaxy()/20,"SUNIL KUMAR DHEENDHWAL");
nosound();
}
getche();
}

HOW TO MAKE Matrix By Sum Of Two MatRix And By Multy Of Two Matrix


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
class A
{
int a[3][3],b[3][3],c[3][3],d[3][3],i,j,z,s,t;
public:
A()
{
cout<<"Enter the element of A matrix = ";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter the element of B matrix = ";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cin>>b[i][j];
}
}
}
A(int x, int y)
{
s=x;
t=y;
}
void sum()
{
z=s+t;
cout<<"sum of 3 and 5 is= "<<z;
}
void fact()
{
cout<<"matrix A is = f\n";

for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<a[i][j];
}
cout<<"\n";
}
cout<<"matrix B is = \n";

for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<b[i][j];
}
cout<<"\n";
}



for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
c[i][j]=a[i][j]*b[i][j];
d[i][j]=a[i][j]+b[i][j];
 }
 }
cout<<"matrix of multy of A and B is= \n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<c[i][j]<<" ";
}
cout<<"\n";
}
cout<<"matrix of sum of A and B is= \n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<d[i][j]<<" ";
}
cout<<"\n";
}
}
};
void main()
{
clrscr();
A x;
x.fact();
A x2(3,5);
x2.sum();

getch();
}