Sunday, 25 December 2011

sound

#include<dos.h>
 
main()
{
int a;
 
for ( a = 200 ; a <= 1000 ; a = a + 20 )
{
sound(a);
delay(25);
}
nosound();
 
return 0;
}

sleep

#include<stdio.h>
#include<dos.h>
 
main()
{
printf("Wait for 5 seconds to exit.\n");
sleep(5);
return 0;
}

setdate

#include<stdio.h>
#include<conio.h>
#include<dos.h>
 
main()
{
struct date d;
 
printf("Enter the new date ( day, month and year ) as integers ");
scanf("%d%d%d",&d.da_day,&d.da_mon,&d.da_year);
 
setdate(&d);
 
printf("Current system date is %d/%d/%d\n",d.da_day,d.da_mon,d.da_year);
 
getch();
return 0;
}
» Share this

nosound

#include<dos.h>
 
main()
{
sound(400);
delay(1000);
nosound();
 
return 0;
}

gettime

#include<stdio.h>
#include<dos.h>
 
main()
{
struct time t;
 
gettime(&t);
 
printf("Current system time is %d : %d : %d\n",t.ti_hour,t.ti_min,t.ti_sec);
 
return 0;
}

getdate

#include<stdio.h>
#include<dos.h>
 
main()
{
struct date d;
 
getdate(&d);
 
printf("Current system date is %d/%d/%d\n",d.da_day,d.da_mon,d.da_year);
 
return 0;
}

delay

#include<stdio.h>
#include<stdlib.h>
 
main()
{
printf("This c program will exit in 10 seconds.\n");
 
delay(10000);
 
return 0;
}

Moving Car

#include <graphics.h>
#include <dos.h>
#include <conio.h>
 
main()
{
int i, j = 0, gd = DETECT, gm;
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(25,240,"Press any key to view the moving car");
 
getch();
setviewport(0,0,639,440,1);
 
for( i = 0 ; i <= 420 ; i = i + 10, j++ )
{
rectangle(50+i,275,150+i,400);
rectangle(150+i,350,200+i,400);
circle(75+i,410,10);
circle(175+i,410,10);
setcolor(j);
delay(100);
 
if( i == 420 )
break;
 
clearviewport();
}
 
getch();
closegraph();
return 0;
}

Saturday, 24 December 2011

textbackground

#include<stdio.h>
#include<conio.h>
 
main()
{
textbackground(RED);
 
cprintf("C program to change background color.");
 
getch();
return 0;
}

Blinking Text

#include<stdio.h>
#include<conio.h>
 
main()
{
textcolor(MAGENTA+BLINK);
cprintf("C programming");
 
getch();
return 0;
}

textcolor

#include<stdio.h>
#include<conio.h>
 
main()
{
textcolor(RED);
cprintf("C programming");
 
getch();
return 0;
}
 
 

wherey

#include<stdio.h>
#include<conio.h>
 
main()
{
int y;
 
printf("Hello\n");
 
y = wherey();
 
printf("Vertical cursor position from where this text appears = %d",y);
 
getch();
return 0;
}

wherex

#include<stdio.h>
#include<conio.h>
 
main()
{
int x;
 
printf("Hello");
 
x = wherex();
 
printf("Horizontal cursor position from where this text appears = %d\n",x);
 
getch();
return 0;
}

kbhit

#include<stdio.h>
#include<conio.h>
 
main()
{
while(!kbhit())
printf("You haven't pressed a key.\n");
 
return 0;
}

gotoxy

#include<stdio.h>
#include<conio.h>
 
main()
{
int x, y;
 
x = 10;
y = 10;
 
gotoxy(x, y);
 
printf("C program to change cursor position.");
 
getch();
return 0;
}
 
 

getche

#include<stdio.h>
#include<conio.h>
 
main()
{
printf("Waiting for a character to be pressed from the keyboard to exit.");
 
getche();
return 0;
}

getch

/* getch in c example */
#include<stdio.h>
#include<conio.h>
 
main()
{
printf("Waiting for a character to be pressed from the keyboard to exit.\n");
 
getch();
return 0;
}

delline

#include<stdio.h>
#include<conio.h>
 
main()
{
printf("This line will be deleted when you press a key.");
 
getch();
delline();
 
printf("Line deleted successfully.");
 
getch();
return 0;
}

clrscr

#include<stdio.h>
#include<conio.h>
 
main()
{
printf("Press any key to clear the screen.\n");
 
getch();
 
clrscr();
 
printf("This appears after clearing the screen.\n");
printf("Press any key to exit...\n");
 
getch();
return 0;
}

sqrt

#include<stdio.h>
#include<math.h>
 
main()
{
double number, result;
 
printf("Enter a number to calculate it's square root ");
scanf("%lf",&number);
 
result = sqrt(number);
 
printf("Square root of %lf = %lf", number, result);
 
return 0;
}
 
 

sin

#include<stdio.h>
#include<math.h>
 
main()
{
double result, x = .75;
 
result = sin(x);
 
printf("The sin(%lf) = %lf\n", x, result);
 
return 0;
}

pow

#include<stdio.h>
#include<math.h>
 
main()
{
double a, b, result;
 
printf("Enter a and b to calculate a^b ");
scanf("%lf%lf",&a, &b);
 
result = pow(a, b);
 
printf("%lf raised to %lf = %lf", a, b, result);
 
return 0;
}
 
 

log10

#include<stdio.h>
#include<math.h>
 
main()
{
double number, result;
 
printf("Enter a number to calculate it's log (base is 10) ");
scanf("%lf",&number);
 
result = log10(number);
 
printf("Common log of %lf = %lf", number, result);
 
return 0;
}

log

#include<stdio.h>
#include<math.h>
 
main()
{
double number, result;
 
printf("Enter a number to calculate it's natural log (base is e) ");
scanf("%lf",&number);
 
result = log(number);
 
printf("Natural log of %lf = %lf", number, result);
 
return 0;
}
 
  

floor

#include<stdio.h>
#include<math.h>
 
main()
{
double number, result;
 
printf("Enter a number to round it down ");
scanf("%lf",&number);
 
result = floor(number);
 
printf("Original number = %lf\n", number);
printf("Number rounded down = %lf", result);
 
return 0;
}
 
 

cos

#include<stdio.h>
#include<math.h>
 
main()
{
double result, x = .25;
 
result = cos(x);
 
printf("The cos(%lf) = %lf\n", x, result);
 
getch();
return 0;
}

ceil

#include<stdio.h>
#include<math.h>
 
main()
{
double number, result;
 
printf("Enter a number to round it up\n");
scanf("%lf",&number);
 
result = ceil(number);
 
printf("Original number = %lf\n", number);
printf("Number rounded up = %lf\n", result);
 
return 0;
}

A Smiling Face Animation

#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
 
main()
{
int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75;
void *p;
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
setcolor(YELLOW);
circle(50,100,25);
setfillstyle(SOLID_FILL,YELLOW);
floodfill(50,100,YELLOW);
 
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(44,85,2,6);
fillellipse(56,85,2,6);
 
ellipse(50,100,205,335,20,9);
ellipse(50,100,205,335,20,10);
ellipse(50,100,205,335,20,11);
 
area = imagesize(left, top, left + 50, top + 50);
p = malloc(area);
 
setcolor(WHITE);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
outtextxy(155,451,"Smiling Face Animation");
 
setcolor(BLUE);
rectangle(0,0,639,449);
 
while(!kbhit())
{
temp1 = 1 + random ( 588 );
temp2 = 1 + random ( 380 );
 
getimage(left, top, left + 50, top + 50, p);
putimage(left, top, p, XOR_PUT);
putimage(temp1 , temp2, p, XOR_PUT);
delay(100);
left = temp1;
top = temp2;
}
 
getch();
closegraph();
return 0;
}
 
 

textwidth

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, width;
char array[100];
 
initgraph(&gd, &gm, "C:\\TC\\BG I");
 
width = textwidth("C programming");
 
sprintf(array,"Textwidth = %d",width);
outtext(array);
 
getch();
closegraph();
return 0;
}

textheight

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, height;
char array[100];
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
height = textheight("C programming");
 
sprintf(array,"Textheight = %d",height);
outtext(array);
 
getch();
closegraph();
return 0;
}

setviewport

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, midx, midy;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
midx = getmaxx()/2;
midy = getmaxy()/2;
 
setviewport(midx - 50, midy - 50, midx + 50, midy + 50, 1);
circle(50, 50, 55);
 
getch();
closegraph();
return 0;
}
 
 

settextstyle

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, x = 25, y = 25, font = 0;
initgraph(&gd,&gm,"C:\\TC\\BIN");
 
for ( font = 0 ; font <= 10 ; font++)
{
settextstyle(font, HORIZ_DIR, 1);
outtextxy(x, y, "Text with different fonts");
y = y + 25;
}
 
getch();
closegraph();
return 0;
}
 
 

setfillstyle

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
setfillstyle(XHATCH_FILL, RED);
circle(100, 100, 50);
floodfill(100, 100, WHITE);
 
getch();
closegraph();
return 0;
}
 
 

setcolor

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
circle(100,100,50); /* drawn in white color */
setcolor(RED);
circle(200,200,50); /* drawn in red color */
 
getch();
closegraph();
return 0;
}
 
 

setbkcolor

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
outtext("Press any key to change the background color to GREEN.");
getch();
 
setbkcolor(GREEN);
 
getch();
closegraph();
return 0;
}

sector

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
sector(100, 100, 0, 135, 25, 35);
 
getch();
closegraph();
return 0;
}

rectangle

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
rectangle(100,100,200,200);
 
getch();
closegraph();
return 0;
}
 
 

putpixel

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
putpixel(25, 25, RED);
 
getch();
closegraph();
return 0;
}

putimage

#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
 
main()
{
int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75;
void *p;
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
setcolor(YELLOW);
circle(50,100,25);
setfillstyle(SOLID_FILL,YELLOW);
floodfill(50,100,YELLOW);
 
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(44,85,2,6);
fillellipse(56,85,2,6);
 
ellipse(50,100,205,335,20,9);
ellipse(50,100,205,335,20,10);
ellipse(50,100,205,335,20,11);
 
area = imagesize(left, top, left + 50, top + 50);
p = malloc(area);
 
setcolor(WHITE);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
outtextxy(155,451,"Smiling Face Animation");
 
setcolor(BLUE);
rectangle(0,0,639,449);
 
while(!kbhit())
{
temp1 = 1 + random ( 588 );
temp2 = 1 + random ( 380 );
 
getimage(left, top, left + 50, top + 50, p);
putimage(left, top, p, XOR_PUT);
putimage(temp1 , temp2, p, XOR_PUT);
delay(100);
left = temp1;
top = temp2;
}
 
getch();
closegraph();
return 0;
}
 
 

pieslice

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
pieslice(200,200,0,135,100);
 
getch();
closegraph();
return 0;
}
 
 

outtextxy

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
outtextxy(100, 100, "Outtextxy function");
 
getch();
closegraph();
return 0;
}

outtext

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
outtext("To display text at a particular position on the screen use outtextxy");
 
getch();
closegraph();
return 0;
}

moverel

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, x, y;
char message[100];
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
moveto(100, 100);
moverel(100, -100);
 
x = getx();
y = gety();
 
sprintf(message, "Current x position = %d and y position = %d", x, y);
outtextxy(10, 10, message);
 
getch();
closegraph();
return 0;
}

moveto

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
char msg[100];
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
sprintf(msg, "X = %d, Y = %d",getx(),gety());
 
outtext(msg);
 
moveto(50, 50);
 
sprintf(msg, "X = %d, Y = %d", getx(), gety());
 
outtext(msg);
 
getch();
closegraph();
return 0;
}

linerel

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
moveto(250, 250);
linerel(100, -100);
 
getch();
closegraph();
return 0;
}

lineto

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
moveto(100, 100);
lineto(200, 200);
 
getch();
closegraph();
return 0;
}

line

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
line(100, 100, 200, 200);
 
getch();
closegraph();
return 0;
}
 
 

imagesize

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, bytes;
char array[100];
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
circle(200, 200, 50);
line(150, 200, 250, 200);
line(200, 150, 200, 250);
 
bytes = imagesize(150, 150, 250, 250);
sprintf(array, "Number of bytes required to store required area = %d", bytes);
outtextxy(10, 280, array);
 
getch();
closegraph();
return 0;
}
 
 

grapherrormsg

#include<graphics.h>
#include<stdlib.h>
#include<conio.h>
 
main()
{
int gd, gm, errorcode;
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
errorcode = graphresult();
 
if(errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to exit.");
getch();
exit(1);
}
 
getch();
closegraph();
return 0;
}

graphdefaults

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
setcolor(RED);
setbkcolor(YELLOW);
 
circle(250, 250, 50);
 
getch();
graphdefaults();
 
getch();
closegraph();
return 0;
}

gety

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, y;
char array[100];
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
y = gety();
 
sprintf(array, "Current position of y = %d", y);
 
outtext(array);
 
getch();
closegraph();
return 0;
}

getx

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
char array[100];
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
sprintf(array, "Current position of x = %d",getx());
 
outtext(array);
 
getch();
closegraph();
return 0;
}

getpixel

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, color;
char array[50];
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
color = getpixel(0, 0);
 
sprintf(array,"color of pixel at (0,0) = %d",color);
outtext(array);
 
getch();
closegraph();
return 0;
}

getmaxy

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, max_y;
char array[100];
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
max_y = getmaxy();
 
sprintf(array, "Maximum Y coordinate for current graphics mode and driver is = %d.",max_y);
outtext(array);
 
getch();
closegraph();
return 0;
}

getmaxx

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, max_x;
char array[100];
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
max_x = getmaxx();
 
sprintf(array, "Maximum X coordinate for current graphics mode and driver = %d.",max_x);
outtext(array);
 
getch();
closegraph();
return 0;
}

getmaxcolor

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, max_colors;
char a[100];
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
max_colors = getmaxcolor();
 
sprintf(a,"Maximum number of colors for current graphics mode and driver = %d",max_colors+1);
outtextxy(0, 40, a);
 
getch();
closegraph();
return 0;
}

getimage

#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
 
main()
{
int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75;
void *p;
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
setcolor(YELLOW);
circle(50,100,25);
setfillstyle(SOLID_FILL,YELLOW);
floodfill(50,100,YELLOW);
 
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(44,85,2,6);
fillellipse(56,85,2,6);
 
ellipse(50,100,205,335,20,9);
ellipse(50,100,205,335,20,10);
ellipse(50,100,205,335,20,11);
 
area = imagesize(left, top, left + 50, top + 50);
p = malloc(area);
 
setcolor(WHITE);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
outtextxy(155,451,"Smiling Face Animation");
 
setcolor(BLUE);
rectangle(0,0,639,449);
 
while(!kbhit())
{
temp1 = 1 + random ( 588 );
temp2 = 1 + random ( 380 );
 
getimage(left, top, left + 50, top + 50, p);
putimage(left, top, p, XOR_PUT);
putimage(temp1 , temp2, p, XOR_PUT);
delay(100);
left = temp1;
top = temp2;
}
 
getch();
closegraph();
return 0;
}
 
 

getdrivername

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
char *drivername;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
drivername = getdrivername();
outtextxy(200, 200, drivername);
 
getch();
closegraph();
return 0;
}

getcolor

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, drawing_color;
char a[100];
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
drawing_color = getcolor();
 
sprintf(a,"Current drawing color = %d", drawing_color);
outtextxy( 10, 10, a );
 
getch();
closegraph();
return 0;
}
» Share this

getbkcolor

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm, bkcolor;
char a[100];
 
initgraph(&gd,&gm,"C:\\TC\\BGI");
 
bkcolor = getbkcolor();
 
sprintf(a,"Current background color = %d", bkcolor);
outtextxy( 10, 10, a);
 
getch();
closegraph();
return 0;
}

getarccoords

#include<graphics.h>
#include<conio.h>
#include<stdio.h>
 
main()
{
int gd = DETECT, gm;
struct arccoordstype a;
char arr[100];
 
initgraph(&gd, &gm,"C:\\TC\\BGI");
 
arc(250,200,0,90,100);
getarccoords(&a);
 
sprintf(arr,"(%d, %d)",a.xstart,a.ystart);
outtextxy(360,195,arr);
 
sprintf(arr,"(%d, %d)",a.xend,a.yend);
outtextxy(245,85,arr);
 
getch();
closegraph();
return 0;
}

floodfill

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
setcolor(RED);
circle(100,100,50);
floodfill(100,100,RED);
 
getch();
closegraph();
return 0;
}
 
 

fillpoly

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd=DETECT,gm,points[]={320,150,440,340,230,340,320,150};
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
fillpoly(4, points);
 
getch();
closegraph();
return 0;
}
 
 

fillellipse

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
fillellipse(100, 100, 50, 25);
 
getch();
closegraph();
return 0;
}
 
 

ellipse

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
ellipse(100, 100, 0, 360, 50, 25);
 
getch();
closegraph();
return 0;
}
 
 

drawpoly

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd=DETECT,gm,points[]={320,150,420,300,250,300,320,150};
 
initgraph(&gd, &gm, "C:\\TC\\BIN");
 
drawpoly(4, points);
 
getch();
closegraph();
return 0;
}
 
 

closegraph

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
outtext("Press any key to close the graphics mode...");
 
getch();
closegraph();
return 0;
}

cleardevice

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
outtext("Press any key to clear the screen.");
getch();
cleardevice();
outtext("Press any key to exit...");
 
getch();
closegraph();
return 0;
}

circle

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
circle(100, 100, 50);
 
getch();
closegraph();
return 0;
}
 
 

Sunday, 11 December 2011

bar3d

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
bar3d(100, 100, 200, 200, 20, 1);
 
getch();
closegraph();
return 0;
}
 
 
 

bar

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
bar(100, 100, 200, 200);
 
getch();
closegraph();
return 0;
}
 
  

arc

#include<graphics.h>
#include<conio.h>
 
main()
{
int gd = DETECT, gm;
 
initgraph(&gd, &gm, "C:\\TC\\BGI");
 
arc(100, 100, 0, 135, 50);
 
getch();
closegraph();
return 0;
}
 
 
 

abs

#include<stdio.h>
#include<math.h>
 
main()
{
int number, result;
 
printf("Enter a number to calculate it's absolute value");
scanf("%d",&number);
 
result = abs(number);
 
printf("Absolute value of %d = %d", number, result);
 
getch();
return 0;
}