Posts

Round Robin & Shortest Job First in C/C++

Image
Hey guys, its project I had worked on. It is used for process scheduling. Please save the file with .cpp extension. Hope you guys like it. Here's the screen shot of the output. Here's the source code, enjoy coding.. /* Pogrammer : Ashok Kumar Shrestha Program: Round Robin and Shortest job first scheduling */ #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> #include<process.h> struct proc { int id; int arrival; int burst; int rem; int wait; int finish; int ti; int turnaround; float ratio; }process[10]; int no,k; int chkprocess(int); int nextprocess1(); int nextprocess(int); void main1(); void rr(); void sjs(); void input(int num); void oppage(int, int); void bar_print(int,int); void table_print(int); void loading() { int d=3,i,x1=120,y1=350,x2=x1+400,y2=y1+15; char arr[10]; cleardevice(); moveto(260,50); setcolor(7); settextstyle(4,0,10); outtext(...

Pie Chart: Using C/C++ and graphics

Image
Hey guys, its very simple illustration of pie chart but it is not exactly how it works. In next post I will post how to take input from user and then generate the pie chart and bar graph. Here is the screen shot of the output. Pie-chart using C/C++ and Graphics Here's the code, enjoy coding.. /*     Programmer : Ashok Kumar Shrestha (ak007)     Program details : Pie chart */ #include<stdio.h> #include<graphics.h> #include<conio.h> int main() {    int gd = DETECT, gm, midx, midy;    initgraph(&gd,&gm,"..\\bgi");    setcolor(11);    rectangle(0,40,639,450);    settextstyle(1,0,2);    midx = getmaxx()/2;    midy = getmaxy()/2;    setfillstyle(2,1);    pieslice(midx, midy, 0, 72, 100);    setfillstyle(3,2);    pieslice(midx, midy, 72, 225, 100);    setfillstyle(4,4);    pieslice(midx, midy, 225, ...

Bar Graph: Using C/C++ and Graphics

Image
Hey guys, today I am going to post simple illustration of bar graph. May be next post I will post how to simulate bar graph with user input. Here is the screen shot of the out put. Bar Graph using C/C++ and Graphics Here is the code, enjoy coding... /*     Progammer : Ashok Kumar Shrestha (ak007)     Program details: Bar Graph */ #include<stdio.h> #include <graphics.h> #include <conio.h> int main() {    int gd = DETECT, gm;    initgraph(&gd,&gm, "..\\bgi");    setfillstyle(1,1);    bar(0,10,639,450);    setcolor(11);    rectangle(0,10,639,450);    line(200,35,450,35);    settextstyle(2,0,7);    setcolor(15);    outtextxy(275,10,"Bar Graph");    line(100,420,100,60);    line(100,420,600,420);    setlinestyle(2,0,7);    outtextxy(95,35,"Y");    outtextxy(610,405,"X");  ...

Smiley Face : Using C/C++ and Graphics

Image
Hey guys, today I am going to post very simple  yet beautiful program. This program generates smiley face at random position with different colors. If you guys like only particular color then eliminate the code to change color in while loop. And also if you like to see bigger or smaller smiley face then change the radius value. Here is the screen output of the code. Here's the code, enjoy coding... /*       Programmer : Ashok Kumar Shrestha (ak007)      Program details : Smiley face using C/C++ and graphics */ #include<graphics.h> #include<conio.h> #include<stdlib.h> #include<dos.h> main() {    int gd = DETECT, gm;    int x,y,color=14,radius=30,count=0;    initgraph(&gd,&gm,"C:\\TC\\BGI");    while(!kbhit())    {    x=rand()%600+20;    y=rand()%600+20;    setfillstyle(1,color);    fillellipse(x,y,radius,r...

Piano : Using C/C++ and Graphics

Image
Hey guys, today I am going to post one awesome program which I have been working for a quiet long time. It's not complete yet though, I will try to complete it soon. It's mini piano which we can play using keyboard. Press the keys as shown in the keyboard layout in the out put screen to play piano. If you want to exit, press Esc key. Here's the screenshot of the output. Here's the code: Note: Please save the file in .cpp extension if it is showing error. Make sure your speaker works properly because this program generates different sound according to key pressed. /*     Programmer: Ashok Kumar Shrestha (ak007)     Program Description: mini piano v 1.0 */ #include<stdio.h> #include<conio.h> #include<dos.h> #include<graphics.h> #include<process.h> getkey() {     union REGS i,o;     while(!kbhit());     i.h.ah=0;     int86(22,&i,&o); ...

Architectural pattern: Using C/C++ and graphics

Image
Hey guys its very simple but beautiful architectural pattern using C/C++ with graphics.  I don't know its name, if you guys know then please leave a comment below. Here's the screen shot of the output. Now, let us see the codes. Here by changing the value of the n we can create different pattern. For this program I have choosen value as 15 but do try with other values also. Here's the code. /*     Programmer: Ashok Kumar Shrestha (ak007)     Program Details: Generates Awesome Circular pattern 3.1 */ #include<graphics.h> #include<conio.h> #include<dos.h> #include<stdio.h> main() {    int gd = DETECT, gm, x, y, color, angle = 0,i,j;        char sstr[20];    int pat[2][200]={0};    int n=15;    struct arccoordstype a, b;    initgraph(&gd, &gm, "..\\BGI");    delay(200); for(i=0;i<n;i++)    {     setco...

Loading..: Using C and graphics

Image
Hey guys, today I am posting a simple program which illustrate loading any videos or files. You might have seen this in while watching videos online. Well, here's the screen shot of the output. Let us see the codes now, hope you guys like it.. /*     Programmer: Ashok Kumar Shrestha (ak007)     Program Details: Generates Circular pattern2.1  for loading */ #include<graphics.h> #include<conio.h> #include<dos.h> main() {    int gd = DETECT, gm, x, y, color, angle = 0;    struct arccoordstype a, b;    initgraph(&gd, &gm, "..\\BGI");    delay(200);    setcolor(11);    settextstyle(1,0,4);    outtextxy(260,380,"Loading...");    while(!kbhit())    {       setcolor(BLACK);       arc(getmaxx()/2,getmaxy()/2,angle,angle+2,100);       setcolor(8);    ...