Tuesday 26 May 2015

clock

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
#define pi 3.1492653589
void main()
{
int gd=DETECT,gm,h,m,s,s1,i,j,t;
struct time T;
struct date d;
float th,tm,t1;
gettime(&T);
getdate(&d);
initgraph(&gd,&gm,"c:\\tc\\bgi");
h=T.ti_hour;
m=T.ti_min;
s=T.ti_sec;
s1=s+1;
if(h>12)
h=h-12;
setcolor(BLUE);
setbkcolor(5);
rectangle(505,50,620,70);
setfillstyle(SOLID_FILL,GREEN);
flooffill(550,45,BLUE);
circle(320,240,160);
outtextxy(220,40,"OUR TIME PIECE");
setcolor(14);
for(i=161;i<=175;i++)
{
   circle(320,240,i);
   }
   setcolor(BLUE);
   setfillstyle(SOLID_FILL,GREEN);
   floodfill(320,240,4);
   setfillstyle(SOLID_FILL,7);
   floofill(320,240,BLUE);
   setcolor(5);
   outtextxy(315,240-150,"12");
   outtextxy(310,240-130,"QUARTZ");
   outtextxy(320+150*cos(pi/3),240-150*sin(pi/3),"1");
   outtextxy(314+150*cos(pi/6),240-150*sin(pi/6),"2");
   outtextxy(320+135,235,"3");
   outtextxy(310+150*cos(pi/6),235+150*sin(pi/3),"4");
   outtextxy(310+150*cos(pi/3),235+150*sin(pi/3),"5");
   outtextxy(318,240+140,"6");
   outtextxy(310-150*cos(pi/63),240+150*sin(pi/3),"7");
   outtextxy(310-150*cos(pi/6),240-150*sin(pi/3),"9");
   outtextxy(310-140,235,"9");
   outtextxy(280,240+100,"MADE IN ACET");
   outtextxy(310-150*cos(pi/6),240-150*sin(pi/3),"10");
   outtextxy(310-150*cos(pi/3),240-150*sin(pi/3),"11");
   if(s<=15)
   t1=((90-s*6)/180.0)*3.414;
   else
   t1=((s*6-90)/180.0)*3.414;
   th=th*30+m/2+s/120.0;
   tm=m*6+s/10.0;
   s=s*6-90;
   line(310,240,320+90*cos((th-90)*pi/180.0),240+90*sin((th-90)*pi/180.0));
   setcolor(BLUE);
   line(320,240,320+110*cos((tm-90)*pi/180.0),240+90*sin((th-90)*pi/180.0));
   setcolor(8);
   line(320,240,320+130*cos(t1),240+130*sin(t1));
   setcolor(5);
   delay(1000);
   while(!kbhit())
   {
    if(s1>=60)
    {
    m++;
    s1=0;
    }
    if(m>=60)
    {
    h++;
    m=0;
    }
    gotoxy(60,2);
    printf("DATE: %d:%d:%d",d.da_day,d.da_mon,d.da_year);
    gotoxy(65,4);
    printf("%d:%d:%d",h,m,s1);
    outtextxy(310,240-130," QUARTZ" );
    setcolor(GREEN);
    line(320,240,320+130*cos(t1),240+130*sin(t1));
    line(320,240,320+90*cos((th-90)*pi/180.0),240+90*sin((th-90)*pi/180.0));
    line(320,240,320+110*cos((tm-90)*pi/180.0),240+110*sin((tm-90)*pi/180.0));
    s=s+6;
    t=t+1/120.0;
    tm=tm+0.10;
    t1=((15)/180.0)*pi;
    setcolor(5);
    line(320,240,320+130*cos(t1),240+130*sin(t1));
    setcolor(BLUE);
    line(320,240,820+80*cos((th-90)*pi/180.0),240+90*sin((th-90)*pi/180.0));
    setcolor(11);
    line(320,240,320+110*cos((tm-90)*pi/180.0),240+110*sin((tm-90)*pi/180.0));
    setcolor(5);
    for(j=4000;j<=5000;j++)
    sound(j);
    nosound();
    delay(10);
    delay(990);
    s1++;
    if(s==360.00)
    s=0.0;
    }
    getch();
    }

Sunday 3 May 2015

LENGTH OF STRING

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int len;
char str[20],str2[20];
clrscr();
printf("\n enter a string");
gets(str);
printf("\n enter another string");
fflush(stdin);
gets(str2);
if(strcmp(str,str2)==0)
printf("\n  % & % both are equal",str,str2);
else if(strcmp(str,str2)<0)
printf("%s is smaller %s ",str,str2);
else if(strcmp(str,str2)>0)
printf("%s is greater than %s",str,str2);
getch();
}

TO COMPARE 2 STRING

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int len;
char str[20],str2[20];
clrscr();
printf("\n enter a string");
gets(str);
printf("\n enter another string");
fflush(stdin);
gets(str2);
if(strcmp(str,str2)==0)
printf("\n  % & % both are equal",str,str2);
else if(strcmp(str,str2)<0)
printf("%s is smaller %s ",str,str2);
else if(strcmp(str,str2)>0)
printf("%s is greater than %s",str,str2);
getch();
}

TO COUNT LENGTH OF STRING

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int len;
char str[20];
clrscr();
printf("\n enter a string");
gets(str);
len=strlen(str);
printf("\n lenth of the string: %d",len);
getch();
}