Posts

C++ Program to print any Matter'

#include<iostream.h> #include<conio.h> void main() { clrscr(); cout<<"Hello Future Programmers.."; getch(); } In c++, "cout" is used to display output..

C Program to read a file with getc using while loop

#include<stdio.h> #include<conio.h> void main() { FILE *fp; char ch; clrscr(); fp=fopen("abc.txt","r"); while(EOF!=(ch=getc(fp))) { printf("%c",ch); } getch(); } Note- The above file contains word "hello"

Circle

C program to draw circle on Screen- Example #include<stdio.h> #include<graphics.h> #include<conio.h> void main() { int gd=DETECT, gm; clrscr(); initgraph(&gd,&gm,"c:\\turboc3\\bgi"); circle(50,60,30);      //circle(int x,int y,radius); getch(); }

rectangle from line()

C program to make rectangle using line function- #include<graphics.h> #include<conio.h> void main() { int gd=DETECT, gm; clrscr(); initgraph(&gd,&gm,"c:\\turboc3\\bgi"); setcolor(3); line(30,15,100,15); line(30,100,30,15); line(30,100,100,100); line(100,100,100,15); getch(); }

Line

C program to make line- #include<graphics.h> #include<conio.h> void main() { int gd=DETECT, gm; clrscr(); initgraph( & gd, & gm,"c:\\turboc3\\bgi"); line(30,15,100,15); getch(); }

C program to plot random color dots on screen

Image
Source Code- #include<graphics.h> #include<conio.h> void main() { int gd=DETECT, gm, i; clrscr(); initgraph(&gd,&gm,"c:\\turboc3\\bgi"); for(i=1;i<=15;i++) { putpixel(20+i*15,30,i); } getch(); closegraph(); } output-

putpixel in c

Image
Function name - putpixel Definition-  putpixel is used to plot a dot on screen at specified position with specified colour. sy ntax- putpixel(int x,int y,pixelcolor); Example c program for putpixel- #include<graphics.h> #include<conio.h> void main() { int gd=DETECT, gm; clrscr(); initgraph(&gd,&gm,"c:\\turboc3\\bgi"); putpixel(20,30,4); getch(); closegraph(); } Output- As you can see red colour dot is placed at (20,30) position.