Learn to Code

CProgramming Expert

The right support in coding is what we provide, and you will be an expert even before you know it.

new kind of learning experience

Learn. Build. Empower.

Our method follows a step by step approach at fulfilling your dreams and turning you into a capable individual at CProgramming.

01. Tutorials

We hit you with the right tutorials to help you get started on the right track.

02. Practice

Since practice is the only thing that takes you to places, we ensure that you get well and more of the same.

03. Resources

The perfect guide comes with valuable resources to help you put your thoughts into action.

Tricks & Insights

Live Online Training

We tend to stick to your level of comfort, as you enjoy tutorials through the medium of the internet.

Join Now
Learning Anything

Lets Code Together!

The journey starts and ends with you, as we never leave you until you tend to be an expert.

Know More
Learn

C Programming

From beginners to advanced levels, we offer the right ingredients that you need to reach the right places.

Beginners

  • The very basics is where we begin everything.
  • In the end, you will no longer be a beginner.

Intermediate

  • This particular stage is where we feed you all the right chords to excel at the end.
  • With compact and classified training, things will move accordingly.

Advanced Programmers

  • The level of advancement is here to take you onboard to a whole new world of professionalism.
  • Through different strategies and approaches, you can call yourself an expert.

Register for Fundamentals of C Programming

From basics to the very principle, we tell you all about C Programming.

Tutorials And Articles

Latest Updates

 

Some Tips That Will Help You Learn How To Program Much Faster

Learn How To Program

Whether you are still pursuing a degree in the computer sciences or whether you are a veteran using GI bill to choose the next mission as a great and self-taught developer or even if you are in a coding boot camp student who is mastering the craft of programming itself, it will always be a struggle indeed. Well, you will need pointers, and you will need some help if you need to be a good coder. That is why, in this guide, I have provided you with some of the best tips that you can get.

1.  You should always learn by doing. You should also always play with the code when you are learning as well. With every single new subject, the sooner that you start playing with the code, the faster you will actually learn given all of the concepts. Even if you end up blazing through the entire chapter of reading and a topic seems straightforward, so straightforward that even a monkey can do it, you will be scratching your head when tasked to implement the code for the very first time. You will be thinking what the syntax was and whatnot. You will need to use it, or you will lose it, because of the evolution of technology, this proverb will hold true even when you are learning to code.

2 .You should try and grasp all of the fundamentals, if you want the long-term benefits. As elementary as it may appear at the first, programming fundamentals will always need to come first. The better you understand them, the easier it is for you to learn all of the advanced concepts as well. Students who have rushed through the beginning of the courses have been known to get stuck as we transition into some more advanced materials and they will also have some trouble initially because they have rushed through the basics. Therefore, if you are someone ditches the first class of computer science 101 or even skip the first tutorial, you should keep in mind that you would be overlooking some of the most important parts of learning.

3. You should try and code by hand. It will sharpen your proficiency, and you will need it to get a job. Computer monitors have been getting thinner, and hard drives have also been getting lighter as well. Programming languages would be more powerful, but coding-by-hand will still remain one of the most effective methods to actually learn how to program. You could do it on a whiteboard, or even in a notebook.

Make sure that you ask for help; you will certainly need it.

Web Designer VS Web Developer: What Is The Difference?

Picture Of Web Designer VS Web Developer: What Is The Difference

Employment for web designers is expected to increase by 20 percent between 2012 and 2022 according to the Bureau of Labor statistics. On the other hand, employment for web developers is expected to rise by 13 percent between 2018 and 2028. These figures make both professions among the fastest in terms of growth compared with other professions.

According to the bureau, the growth is going to be driven by demand in e-commerce and mobile phones. Unfortunately, many people use the terms interchangeably which is wrong. This confusion, in part, is because there are people who can do both. However, the two professions play different roles in the building and design of websites. The two professions as well require a different set of skills.

A web designer is a person that is concerned with the aesthetics of a website. Web designers employ the use of design applications like Adobe Photoshop to design visual elements like the layout and others for a website. The web designer helps make sure that the website is easy to use and easy to understand by the end-users.

A developer, on the other hand, is a person that works with the finished products of the web designer in creating functional websites. Using programming languages like CSS, JavaScript, HTML, PHP and a host of others, web developers can bring web design files to life.

What Does a Web Designer Do?

The main job of a web designer like the name states is to design websites. They define and deal with decisions that concerning designs that might not be immediately apparent on seeing the webpage or website for the first time like in the Winnipeg web design.

The work is very important as they define the aesthetic aspect of the website. The aesthetics including the fonts, the colors, the layout and the images which all together sums up the personality of the website. The website designer, in addition to designing the aesthetic aspects, is charged with the responsibility of making the website useable.

The usability is by far one of the most important priorities of the web designer. With proper usability, one would create a website that the target audience can relate to properly. For example, a website designed for children would be one that has lots of images. Such websites would employ the use of easy-to-read texts as well as bright colors.

All these features would be done in a bid to make the website very catchy for the target audience—children. The web designer ensures that information on the website is easy to access.

In designing a website, the designer would first understand the client’s objectives. After the objectives are fully understood, the designer then sets the website’s information hierarchy using what is called the Information Architecture (AI). It will be a guide throughout the design process.

The next stage is to create wireframes after which the design phase starts properly. In creating appealing as well as useable websites, designers employ a range of design principles, they include:

1. Balance:

In web design, large and dark colors are referred to as heavy elements while small and light colors are called light elements. For a web designer to make a visually appealing website, he must strike a balance between the heavy and light elements he uses. Achieving the right balance for a website, therefore, would imply using the right proportions of both elements as appropriate.

2. Contrast:

By alternating contrasting colors, shapes, sizes, and textures, the designer aims at drawing the attention of the end-users to the various sections of the website. The contrast in colors refers to colors that are directly opposite one another on the color wheel.

3. Emphasis:

This principle involves the deliberate highlight of few but important information on the website. It is important to note the words “few” and “important”. The purpose of emphasis becomes defeated when too many items are highlighted on the website.  It is somehow related to contrast in that contrast can be used in making emphasis on a website.

4. Consistency:

This principle decides the general user experience for the website visitors. It is also known as rhythm or repetition. This principle is considered critical in that consistent navigation alongside a clean one will lead to the best experience for end-users.

5. Unity:

According to the Gestalt theory, unity refers to how the human brain organizes information visually by grouping elements into categories.  Unity describes the relationship between the different parts of the layout and the composition of the website as a whole.

What Does A Web Developer Do?

Picture Of What Does a Web Designer Do

Web developers are concerned with the transformation of the designs from Web designers into full-functioning web sites. They are also called programmers because lol they make use of programming languages like PHP, Html, etc. in developing webpages.

It is done by taking the designs of the web designer and breaking it into components. They may also use Content Management systems like Joomla or WordPress to allow the clients’ easy maintenance and update of their websites. Web developers are usually of three types:

1. Back-End Web Developers:

These developers are concerned with creating the basic framework of the website as well as ensuring that the website works well as it should. They are in charge of establishing procedures that allow others to add new pages to the entire website.

2. Front-End Developers:

The front end developers integrate the website’s graphics, applications (for example check out tool), and other content. They work with programming languages such as Html, JavaScript, etc.

3. Webmasters:

These developers are in charge of making sure that the website functions properly after it has been created. They work to maintain and update the website as often as required. By checking for errors like broken links, they ensure that the website functions as it should. Sometimes, webmasters can as well respond to comments on websites.

Conclusion

The work description for both web designers and web developers, although well defined as you have seen here, still overlap in a lot of areas. This overlapping gives rise to popular misconceptions about who is who. With many people seeing them as essentially the same because there are individuals that do both.

However, most tech companies would prefer to have dedicated web designers and web developers separately. On average, a web designer earns between $18,000 for starters and $30,000 for those with experience. While for developers, the average annual earnings are about $69,430.

Dynamic Memmory Allocation

malloc()

             The malloc()  function dynamically allocates memory when required. This function allocates ‘size’ byte of memory and returns a pointer to the first byte or NULL if there is some kind of error.The storage is not initialized.

For example:
               int *ptr = malloc(sizeof(int) * 10);      // allocates 10 ints!

                 If it is unable to find the requested amount of memory, malloc() function returns NULL. So you should really check the result for errors:

int *ptr = malloc(sizeof(int) * 5000);
if (ptr == NULL)
       {
       printf(” Out of memory!\n”);
       exit(1);
       }

                 There are only two ways to get allocated memory back. They are exit from the program and calling free() to free function. If your program runs a while and keeps malloc()ing and never free()ing when it should, it is said to “leak” memory. Make sure to avoid memory leaks! free() that memory when you are done with it!

The following example illustrates the use of  malloc() function.

Home

Union

 Union is a data type with two or more member similar to structure but in this case all the members share a common memory location. The size of the union corresponds to the length of the largest member. Since the member share a common location they have the same starting address.

                    The real purpose of unions is to prevent memory fragmentation by arranging for a standard size for data in the memory. By having a standard data size we can guarantee that any hole left when dynamically allocated memory is freed will always be reusable by another instance of the same type of union. This is a natural strategy in system programming where many instances of different kinds of variables with a related purpose and stored dynamically.

                          A union is declared in the same way as a structure.The syntax of union declaration is
union union_name
         {
          type element 1;
          type element 2;
          ……………..
          type element n;
         };
     This declares a type template. Variables are then declared as:
                           union union_name x,y,z;

                             For example, the following code declares a union data type called Student and a union variable called stud:
union student
             {
             int rollno;
             float totalmark;
             };
union student stud;

                              It is possible to combine the declaration of union combination with that of the union variables, as shown below.
union union_name
           {
           type element 1;
           type element 2;
           ……………..
           type element n;
           }var1,var2,…,varn;       

                               The following single declaration is equivalent to the two declaration presented in the previous example.
union student
          {
           int rollno;
           float totalmark;
          }x,y,z;

Exercise: Compare structure and Union

Structure:

Union:

Home

Return statement

  • A function may or may not return a value. A return statement returns a value to the calling function and assigns to the variable in the left side of the calling function.
  • If a function does not return a value, the return type in the function definition and declaration is specified as void.

Example :

123456789101112131415161718192021

222324252627282930313233

3435363738394041424344454647484950515253

54555657585960616263646

5666768697071727374757677787980818

2838485868788899091929394959697

9899100101102103104105106107108109110111112

#include <stdio.h>  #include <conio.h>  void function1();  void function2();  int function3();  int function4();  int main() 

Home

Graphics

Web page Under construction!

The following functions compose the Borland Graphics Interface and are usually available for 16 bit DOS applications. Use them to create onscreen graphics with text. They are defined in graphics.h.

     
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 getch();
 closegraph();      /* closes down the graphics system */
 return 0;
}
     
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)  
    { 
    printf("Graphics error occurred");
    printf("Press any key to halt:");
    getch();     /* wait for a key */
    exit(1);
    }
     
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)  
    { 
    printf("Graphics error occurred");
    printf("Press any key to halt:");
    getch(); 
    exit(1); 
    }
 outtext("Welcome to Borland Graphics Interface");       
/* output the message */
 getch();
 closegraph();
 return 0;
}





     
//outtextxy
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)   
    { 
    printf("Graphics error occurred");
    printf("Press any key to halt:");
    getch();
    exit(1); 
    }
 outtextxy(175,250,"Welcome to Borland Graphics Interface");
 getch();
 closegraph();
 return 0;
}
     
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
//outtextxy
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
    {
    printf("Graphics error occurred");
    printf("Press any key to halt:");
    getch();
    exit(1);
    }
 setbkcolor(BLUE);
 outtextxy(175,250,"Welcome to Borland Graphics Interface");
 getch();
 closegraph();
 return 0;
}
     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,error,maximumcolor;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
    { 
    printf("Graphics error occurred");
    printf("Press any key to halt:");
    getch();
    exit(1); 
    }
 maximumcolor = getmaxcolor();
 for (i=0; i<=maximumcolor;i++)
   {
   setbkcolor(i);    
   outtextxy(175,250,"Welcome to Borland Graphics Interface");   
   outtextxy(getmaxx()-250,getmaxy()-40,"www.CProgrammingExpert.com"); 
   getch();
   }
 getch();
 closegraph();
 return 0;
}
     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,error,maximumcolor;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1); 
 }
 maximumcolor = getmaxcolor();
 for (i=0; i<=maximumcolor;i++)
 {
 setbkcolor(i); 
 sprintf(message, "Background color: %d",i); /* create a message string */
 outtextxy(250, 240,message); 
 outtextxy(getmaxx()-250,getmaxy()-40,"www.CProgrammingExpert.com");
 getch();
 }
 getch();
 closegraph();
 return 0;
}
     
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,error,maximumcolor;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1); 
 }
 maximumcolor = getmaxcolor();
 for (i=0; i<=maximumcolor;i++)
 {
 cleardevice(); /* clear the screen */
 setbkcolor(i); 
 sprintf(message, "Background color: %d",i);
 outtextxy(250, 240,message); 
 outtextxy(getmaxx()-250,getmaxy()-40,"www.CProgrammingExpert.com"); 
 getch();
 }
 getch();
 closegraph();
 return 0;
}
     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,error,maximumcolor;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1); 
 }
 setbkcolor(BLUE);
 maximumcolor = getmaxcolor();
 for (i=0; i<=maximumcolor;i++)
 {
 cleardevice(); 
 setcolor(i); 
 sprintf(message, "Graphics color: %d",i);
 outtextxy(250, 240,message); 
 outtextxy(getmaxx()-250,getmaxy()-40,"www.CProgrammingExpert.com");
 getch();
 }
 getch();
 closegraph();
 return 0;
}
     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,j=0,error,maximumcolor;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 for (i=1; i<11; i++)
 {
 /* select the text style, direction, and size */
 settextstyle(SANS_SERIF_FONT, HORIZ_DIR, i);
 sprintf(message, "Size: %d", i);
 outtextxy(1,j, message);
 /* advance to the next text line */
 j += textheight(message);
 }
 getch();
 closegraph();
 return 0;
}
     
/* textwidth example */
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,j=0,k=0,error,maximumcolor;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 j = getmaxy() / 2;
 settextjustify(LEFT_TEXT, CENTER_TEXT);
 for (i = 1; i < 11; i++)
 {
 settextstyle(SANS_SERIF_FONT, HORIZ_DIR, i);
 sprintf(message, "Size: %d", i);
 outtextxy(k, j, message);
 /* advance to the end of the text */
 k+= textwidth(message);
 }
 getch();
 closegraph();
 return 0;
}
     
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 char range[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 sprintf(range, "X values range from 0..%d", getmaxx());
 outtextxy( getmaxx()/2,getmaxy()/2 ,range);
 outtextxy(getmaxx()-250,getmaxy()-40,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 char range[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 sprintf(range, "Y values range from 0..%d", getmaxy());
 outtextxy( getmaxx()/2,getmaxy()/2 ,range);
 outtextxy(getmaxx()-250,getmaxy()-40,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
//delay
int main()
 {
 int gd=DETECT,gm,error,i;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 for(i=0;i<=getmaxy();i++)
 {
 cleardevice();
 sprintf(message, ".<<---(x=0,y=%d) :: www.CProgrammingExpert.com",i);
 outtextxy( 0,i ,message);
 delay(100);
 }
 getch();
 closegraph();
 return 0;
}

     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
//delay
int main()
 {
 int gd=DETECT,gm,error,i;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 for(i=0;i<=getmaxx();i++)
 {
 cleardevice();
 sprintf(message, ".<<---(x=%d,y=10) :: www.CProgrammingExpert.com",i);
 outtextxy( i,10 ,message);
 delay(100);
 }
 getch();
 closegraph();
 return 0;
}

     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,error;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 for(i=1;i<=150;i+=10)
 {
 cleardevice();
 arc (310,250,360-i, (360-i)+150,i); 
 //void arc (int x, int y, int startangle, int endangle, int radius);
 outtextxy(getmaxx()-200,getmaxy()-100,"Center:(310,250)");
 sprintf(message, "Radius : %d",i);
 outtextxy(getmaxx()-200,getmaxy()-80,message);
 sprintf(message, "Start angle : %d ",360-i);
 outtextxy(getmaxx()-200,getmaxy()-60,message);
 sprintf(message, "End angle : %d",(360-i)+150);
 outtextxy(getmaxx()-200,getmaxy()-40,message);
 getch();
 }
 cleardevice();
 for(i=1;i<=150;i+=10)
 arc (310,250,360-i, (360-i)+150,i);
 outtextxy(getmaxx()-250,getmaxy()-40,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 bar (320,250, 250, 10);
 outtextxy(getmaxx()-200,getmaxy()-100,"Left : 320");
 outtextxy(getmaxx()-200,getmaxy()-80,"Top : 250");
 outtextxy(getmaxx()-200,getmaxy()-60,"Right : 250");
 outtextxy(getmaxx()-200,getmaxy()-40,"Bottom : 10");
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1); 
 }
 setbkcolor(BLUE);
 bar3d(320,250, 250, 50,35,125);
 outtextxy(getmaxx()-200,getmaxy()-140,"Left : 250");
 outtextxy(getmaxx()-200,getmaxy()-120,"Top : 250");
 outtextxy(getmaxx()-200,getmaxy()-100,"Right : 250");
 outtextxy(getmaxx()-200,getmaxy()-80,"Bottom : 50");
 outtextxy(getmaxx()-200,getmaxy()-60,"Depth : 35");
 outtextxy(getmaxx()-200,getmaxy()-40,"Top Flag : 125");
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,error;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1); 
 }
 setbkcolor(BLUE);
 for(i=10;i<=210;i+=10)
 {
 cleardevice();
 circle (320, 250,i); 
 outtextxy(getmaxx()-200,getmaxy()-60,"Center : (320,250)");
 sprintf(message, "Radius : %d",i);
 outtextxy(getmaxx()-200,getmaxy()-40,message);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 }
 cleardevice();
 for(i=10;i<=210;i+=10)
 circle (320, 250,i);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 int poly[10],maxx, maxy;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1); 
 }
 setbkcolor(BLUE);
 maxx = getmaxx();
 maxy = getmaxy();
 poly[0] = 30; /* first vertex */
 poly[1] = maxy / 2;
 poly[2] = maxx - 30; /* second vertex */
 poly[3] = 30;
 poly[4] = maxx - 75; /* third vertex */
 poly[5] = maxy - 30;
 poly[6] = maxx / 2; /* fourth vertex */
 poly[7] = maxy / 2;
 poly[8] = poly[0]; /* drawpoly doesn't automatically close */
 poly[9] = poly[1]; /* the polygon, so we close it */
 drawpoly(5, poly); /* draw the polygon */
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,poly[10],maxx, maxy,i,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1); 
 }
 setbkcolor(BLUE);
 maxx = getmaxx();
 maxy = getmaxy();
 poly[0] = 30; 
 poly[1] = maxy / 2;
 poly[2] = maxx - 30; 
 poly[3] = 30;
 poly[4] = maxx - 75; 
 poly[5] = maxy - 30;
 poly[6] = maxx / 2; 
 poly[7] = maxy / 2;
 poly[8] = poly[0]; /* drawpoly doesn't automatically close */
 poly[9] = poly[1]; 
 for (i=EMPTY_FILL; i     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,i;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 line(0, 0, getmaxx(), getmaxy()); /* draw a line */
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,j,error;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 for(i=50,j=100;i<=100;i+=10,j+=20)
 {
 cleardevice();
 ellipse (getmaxx()/2,getmaxy()/2,0,360,j+75, j); //<<<<<<<<<
 line(getmaxx()/2,getmaxy()/2,(getmaxx()/2)+j+75,getmaxy()/2);
 line(getmaxx()/2,getmaxy()/2,getmaxx()/2,(getmaxy()/2)-j);
 sprintf(message, "Center (%d,%d)",getmaxx()/2,getmaxy()/2);
 outtextxy(getmaxx()-200,getmaxy()-120,message);
 outtextxy(getmaxx()-200,getmaxy()-100,"Start agle : 0");
 outtextxy(getmaxx()-200,getmaxy()-80,"End angle : 360");
 sprintf(message, "xradius: %d ",j+75);
 outtextxy(getmaxx()-200,getmaxy()-60,message);
 sprintf(message, "yradius : %d",j);
 outtextxy(getmaxx()-200,getmaxy()-40,message);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 }
 cleardevice();
 for(i=50,j=100;i<=100;i+=10,j+=20)
 ellipse (getmaxx()/2,getmaxy()/2,0,360,j+75,j);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,i,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 /* loop through the fill patterns */
 for (i = EMPTY_FILL; i < USER_FILL; i++)
 {
 /* set fill pattern */
 setfillstyle(i, getmaxcolor());
 /* draw a filled ellipse */
 fillellipse(getmaxx() / 2, getmaxy() / 2,200, 150);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 }
 getch();
 closegraph();
 return 0;
}


     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* floodfill example */
#include <stdlib.h>
int main()
 {
 int gd=DETECT,gm,i,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setcolor(getmaxcolor()); /* select drawing color */
 setfillstyle(SOLID_FILL, getmaxcolor()); /* select fill color */
 rectangle(0, 0, getmaxx(), getmaxy()); /* draw a border around the screen */
 circle(getmaxx() / 3, getmaxy() /2, 50);
 circle(getmaxx()-20, 10, 50);
 circle(100, 100, 50);
 circle(getmaxx() / 2, 20, 100);
 circle(getmaxx()-75, getmaxy()-25, 200);
 circle(20, getmaxy()-20, 25);
 getch();
 floodfill(2, 2, getmaxcolor()); /* fill in bounded region */
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* getarccoords example */
int main()
 {
 int gd=DETECT,gm,error,stangle = 90, endangle = 360;
 struct arccoordstype info;
 char message1[80], message2[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setcolor(getmaxcolor());
 arc(getmaxx() / 2, getmaxy() / 2, stangle, endangle, 100); /* draw arc */
 getarccoords(&info;);
 /* convert arc information into strings */
 sprintf(message1, "*- (%d, %d)", info.xstart, info.ystart);
 sprintf(message2, "*- (%d, %d)", info.xend, info.yend);
 outtextxy(info.xstart, info.ystart, message1);
 outtextxy(info.xend, info.yend, message2);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* getaspectratio example */
int main()
 {
 int gd=DETECT,gm,error,xasp, yasp;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setcolor(getmaxcolor());
 getaspectratio(&xasp;, &yasp;); /* get current aspect ratio settings */
 circle( getmaxx() / 2, getmaxy() / 2, 100);
 getch();
 cleardevice();
 setaspectratio(xasp/2, yasp);
 circle( getmaxx() / 2, getmaxy() / 2, 100); /* draw wide circle */
 getch();
 cleardevice();
 setaspectratio(xasp, yasp/2);
 circle( getmaxx() / 2, getmaxy() / 2, 100);
 getch();
 cleardevice();
 setaspectratio(xasp, yasp);
 circle( getmaxx() / 2, getmaxy() / 2, 100);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* getfillpattern example */
int main()
 {
 int gd=DETECT,gm,error;
 char pattern[8] = {0x00, 0x70, 0x20,0x27, 0x25, 0x27, 0x04, 0x04};
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setcolor(getmaxcolor());
 setfillpattern(pattern,getmaxcolor()); /* select a user-defined fill pattern */
 bar(30, 30, getmaxx()-30, getmaxy()-30);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 getfillpattern(pattern); /* get the current user-defined fill pattern */
 pattern[0] -= 5; /* alter the pattern we grabbed */
 pattern[1] -= 10;
 pattern[2] += 10;
 pattern[3] -= 15;
 setfillpattern(pattern, getmaxcolor()); 
 /* fill the screen with the new pattern */
 bar(30, 30, getmaxx()-30, getmaxy()-30);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
 }


     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* getbkcolor example */
int main()
 {
 int gd=DETECT,gm,error,color;
 char name[35];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setcolor(getmaxcolor());
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 color = getbkcolor(); 
 itoa(color, name, 10); /* convert color value into a string */
 strcat(name, " is the current background color.");
 /* display a message */
 outtextxy(getmaxx() / 2, getmaxy() / 2, name);
 outtextxy(getmaxx()-125,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include
/* getpixel example */
#define PIXEL_COUNT 1000
#define DELAY_TIME 100 /* in milliseconds */
int main()
 {
 int gd=DETECT,gm,error,i, x, y, color, maxcolor, seed;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 maxcolor = getmaxcolor() + 1;
 while (!kbhit()) 
 {
 seed = random(32767); 
 srand(seed); /* seed the random number generator */
 for (i=0; i     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
//clearviewport()
int main()
 {
 int gd=DETECT,gm,error,height;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setcolor(getmaxcolor());
 height = textheight("l");
 outtextxy(0, 0, "* <-- (0, 0) in default viewport");
 setviewport(150, 150, getmaxx()-150, getmaxy()-150, 1); /* create a new viewport */
 outtextxy(0, 0, "* <-- (0, 0) in new viewport");
 outtextxy(0, 2*height, "Press any key to clear viewport:");
 getch();
 clearviewport(); /* clear the viewport */
 outtextxy(0, 0, "Press any key to quit:");
 outtextxy(getmaxx()-300,getmaxy()-10,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
//settextjustify
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2, getmaxy() / 2, "Press a key to close the graphics system:");
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 printf("Hi,We're now back in text mode.\n");
 printf("Press any key to halt:");
 getch();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
//detectgraph
#include 
/* the names of the various cards supported */
char *dname[] = { "requests detection",
"a CGA",
"an MCGA",
"an EGA",
"a 64K EGA",
"a monochrome EGA",
"an IBM 8514",
"a Hercules monochrome",
"an AT&T; 6300 PC",
"a VGA",
"an IBM 3270 PC"
};
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 clrscr();
 printf("You have %s video display card.\n", dname[gd]);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 printf("Press any key to halt:");
 getch();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* getcolor example */
int main()
 {
 int gd=DETECT,gm,error;
 int color, midx, midy;
 char colname[35];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setcolor(getmaxcolor());
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 color = getcolor(); /* get the current drawing color */
 itoa(color, colname, 10); /* convert color value into a string */
 strcat(colname, " is the current drawing color.");
 outtextxy(getmaxx() / 2, getmaxy() / 2, colname);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* getdrivername example */
int main()
 {
 int gd=DETECT,gm,error;
 char *drivername;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setcolor(getmaxcolor());
 drivername = getdrivername(); /* get the name of the device driver in use */
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 strcat(drivername," is currently loaded driver");
 outtextxy(getmaxx() / 2, getmaxy() / 2, drivername); /* output the name of the driver */
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}


     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 struct fillsettingstype fillinfo;
 char message1[50], message2[50];
 char *fillname[] = { "EMPTY_FILL", "SOLID_FILL", "LINE_FILL",
"LTSLASH_FILL", "SLASH_FILL","BKSLASH_FILL", "LTBKSLASH_FILL",
"HATCH_FILL", "XHATCH_FILL", "INTERLEAVE_FILL", "WIDE_DOT_FILL",
"CLOSE_DOT_FILL", "USER_FILL" }; /* The names of the fill styles supported */
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 getfillsettings(&fillinfo;); /* get info about current fill pattern and color */
 sprintf(message1, "%s is the fill style.", fillname[fillinfo.pattern]);
 sprintf(message2, "%d is the fill color.", fillinfo.color);
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2, (getmaxy() / 2)-2*textheight("l"), message1);
 outtextxy(getmaxx() / 2, (getmaxy() / 2)+2*textheight("l"), message2);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
 }

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,mode;
 char strnumber[80], strmode[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 mode = getgraphmode(); /* get mode number and name strings */
 sprintf(strnumber, "%d is the current mode number.", mode);
 sprintf(strmode, "%s is the current graphics mode.", getmodename(mode));
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2, getmaxy() / 2, strnumber);
 outtextxy(getmaxx() / 2, (getmaxy() / 2)+2*textheight("l"), strmode);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 struct linesettingstype lineinfo;
 char linestyle[80], linepattern[80], linewidth[80];
 char *linename[] = { "SOLID_LINE", "DOTTED_LINE", "CENTER_LINE",
"DASHED_LINE", "USERBIT_LINE" }; 
/* the names of the line styles supported */
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 getlinesettings(&lineinfo;); /* get information about current line settings */
 sprintf(linestyle, "%s is the line style.", linename[lineinfo.linestyle]);
 /* convert line information into strings */
 sprintf(linepattern, "0x%X is the user-defined line pattern.",lineinfo.upattern);
 sprintf(linewidth, "%d is the line thickness.", lineinfo.thickness);
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2,getmaxy() / 2, linestyle);
 outtextxy(getmaxx() / 2, (getmaxy() / 2)+2*textheight("l"), linepattern);
 outtextxy(getmaxx() / 2, (getmaxy() / 2)+4*textheight("l"), linewidth);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 char colstr[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 sprintf(colstr, "This mode supports colors 0..%d", getmaxcolor()); 
/* grab the color info. and convert it to a string */
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2,getmaxy() / 2, colstr);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 char modestr[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 sprintf(modestr, "This driver supports modes 0..%d",getmaxmode());
 /* grab the mode info. and convert it to a string */
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2,getmaxy() / 2, modestr);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,mode;
 char strnumber[80], strmode[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 mode = getgraphmode(); /* get mode number and name strings */
 sprintf(strnumber, "%d is the current mode number.", mode);
 sprintf(strmode, "%s is the current graphics mode.",getmodename(mode));
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2, getmaxy() / 2, strnumber);
 outtextxy(getmaxx() / 2, (getmaxy() / 2)+2*textheight("W"), strmode);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setwritemode(XOR_PUT); /* select XOR drawing mode */
 line(0, 0, getmaxx(), getmaxy());
 getch();
 line(0, 0, getmaxx(), getmaxy()); /* erase the line by drawing over it */
 getch();
 setwritemode(COPY_PUT); /* select overwrite drawing mode */
 line(0, 0, getmaxx(), getmaxy());
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gdriver = EGA, gmode = EGAHI, error,height;
 initgraph(&gdriver;,&gmode;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 height = textheight("l");
 setactivepage(1); /* select the off screen page for drawing */
 circle(getmaxx()/2,getmaxy()/2,150); /* draw a circle on page #1 */
 settextjustify(CENTER_TEXT, CENTER_TEXT); 
/* output a message on page #1 */
 outtextxy(getmaxx() / 2, getmaxy() / 2, "This is page #1:");
 outtextxy(getmaxx() / 2, (getmaxy() / 2)+height, "Press any key to halt:");
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 setactivepage(0); /* select drawing to page #0 */
 ellipse (getmaxx()/2,getmaxy()/2,0,360,150, 100);
 outtextxy(getmaxx() / 2, getmaxy() / 2, "This is page #0.");
 outtextxy(getmaxx() / 2, (getmaxy() / 2)+height, "Press any key to view page #1:");
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 /* select page #1 as the visible page */
 setvisualpage(1);
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,a,b,result;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 circle(getmaxx()/2,getmaxy()/2,175);
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2, getmaxy() / 2, "Press a key to close the graphics system:");
 getch();
 closegraph(); /* closes down the graphics system */
 printf("*****We're now back in text mode.*****\n\n");
 printf("Enter two numbers\n");
 scanf("%d%d",&a;,&b;);
 result=a+b;
 printf("\nSum of %d and %d is %d\n\nOK!",a,b,result);
 getch();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,i;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
 moveto(getmaxx() / 2, getmaxy() / 2); /* move to the text starting position */
 outtext("Norm ");
 setusercharsize(1, 2, 1, 1); outtext("Short "); /* make the text 1/2 the normal width */
 setusercharsize(3, 1, 1, 1); outtext("Wide"); /* make the text 3 times normal width */
 settextstyle(GOTHIC_FONT, HORIZ_DIR, 1);
 outtextxy(getmaxx()/2,getmaxy()-30,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* the names of the text styles supported */
char *styles[] = { "DEFAULT font", "TRIPLEX font",
"SMALL font", "SANS SERIF_font",
"GOTHIC_font", "SCRIPT font","SIMPLEX font", 
"TRIPLEX SCRIPT font","COMPLEX font", 
"EUROPEAN font","BOLD font"};
int main()
 {
 int gd=DETECT,gm,error,i,style,size = 1;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 for (i=DEFAULT_FONT; i<=BOLD_FONT; i++) 
/* loop through the available text styles */
 {
 cleardevice();
 if (i == TRIPLEX_FONT)
 size = 3;
 settextstyle(i, HORIZ_DIR, size); /* select the text style */
 outtextxy( getmaxx() / 2, getmaxy() / 2,styles[i]);
 outtextxy(getmaxx()-250,getmaxy()-25,"www.CProgrammingExpert.com");
 getch();
 }
 closegraph();
 return 0;
 }

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,i, height, j=0;
 struct palettetype type;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 getpalette(&type;); /* grab a copy of the palette */
 for (i=0; i     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,x,y;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 x=getmaxx() / 2;
 y=getmaxy() / 2;
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 rectangle(x-175, y-50, x+175, y+50);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 outtextxy(x, y, "Press any key to exit graphics");
 getch();
 restorecrtmode(); /* restore system to text mode */
 printf("We're now in text mode.\n");
 printf("Press any key to return to graphics mode:");
 getch();
 setgraphmode(getgraphmode()); /* return to graphics mode */
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 setbkcolor(BLUE);
 outtextxy(x, y, "We're back in graphics mode.");
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 outtextxy(x, y+2*textheight("l"), "Press any key to return to text mode:");
 getch();
 restorecrtmode(); /* restore system to text mode */
 printf("We're now in text mode.\n");
 printf("Press any key to halt:");
 getch();
 closegraph();
 return 0;
 }

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
char *linename[] = { "SOLID_LINES", "DOTTED_LINES",
 "CENTER_LINES","DASHED_LINES", "USERBIT_LINES" }; 
/* The names of the line styles supported */
int main()
 {
 int gd=DETECT,gm,error,i;
 int style, midx, midy, userpat;
 char stylename[25],message[25];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 midx = getmaxx() / 2;
 midy = getmaxy() / 2;
 userpat = 1;
for(i=1;i<=3;i++)
 {
 for (style=SOLID_LINE; style<=USERBIT_LINE; style++)
 {
 sprintf(message, "Line thickness : %d",i);
 outtextxy(midx-75, midy-100, message);
 setlinestyle(style, userpat, i); /* select the line style */
 strcpy(stylename, linename[style]); /* convert style into a string */
 rectangle(10, 10, getmaxx()-10, getmaxy()-10);
 line(10, 10, midx-10, midy);
 line(midx-10, midy, getmaxx()-10,getmaxy()-10);
 line(midx-10, midy, getmaxx()-10,10);
 line(midx-10, midy,10,getmaxy()-10);
 outtextxy(midx, midy, stylename);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 cleardevice();
 }
 getch();
 }
closegraph();
return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error, color, maxcolor, height,y = 10;
 char msg[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 maxcolor = getmaxcolor();
 height = 2 * textheight("l");
 for (color=1; color<=maxcolor; color++) /* display the default colors */
 {
 setcolor(color);
 sprintf(msg, "Color: %d", color);
 outtextxy((getmaxx()/2)-50, y, msg);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 y += height;
 }
 getch();
 for (color=1; color<=maxcolor; color++) /* red out the colors one by one */
 {
 setpalette(color, RED);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 }
closegraph();
return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#define BUFSIZE 1000 /* internal graphics buffer size */
int main()
 {
 int gd=DETECT,gm,i,error;
 int x, y, oldsize;
 char msg[80];
 oldsize = setgraphbufsize(BUFSIZE); 
/* Set size of internal graphics buffer before calling initgraph*/
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 x = getmaxx() / 2;
 y = getmaxy() / 2;
 sprintf(msg, "Graphics buffer size: %d", BUFSIZE);
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(x, y-25, msg);
 sprintf(msg, "Old graphics buffer size: %d", oldsize);
 outtextxy(x, y+2*textheight("l"), msg);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* the names of the fill styles supported */
char *fname[] = { "EMPTY_FILL", "SOLID_FILL", "LINE_FILL",
"LTSLASH_FILL", "SLASH_FILL", "BKSLASH_FILL", 
"LTBKSLASH_FILL","HATCH_FILL", "XHATCH_FILL", 
"INTERLEAVE_FILL", "WIDE_DOT_FILL",
"CLOSE_DOT_FILL", "USER_FILL" };
int main()
 {
 int gd=DETECT,gm,error,i;
 int style, midx, midy;
 char stylestr[40];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 midx = getmaxx() / 2;
 midy = getmaxy() / 2;
 for (style = EMPTY_FILL; style < USER_FILL; style++)
 {
 setfillstyle(style, getmaxcolor()); /* select the fill style */
 strcpy(stylestr, fname[style]); /* convert style into a string */
 /* fill a bar */
 bar3d(midx-125, midy-125, midx+10, midy, 10, 10);
 outtextxy(midx+10, midy, stylestr);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 cleardevice();
 }
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,left, top, right, bottom;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 left = getmaxx() / 2 -200;
 top = getmaxy() / 2 - 200;
 right = getmaxx() / 2 + 200;
 bottom = getmaxy() / 2 + 200;
 rectangle(left,top,right,bottom); /* draw a rectangle */
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error, midx, midy, i;
 int stangle = 0, endangle = 270, xrad = 200, yrad = 150;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 midx = getmaxx() / 2;
 midy = getmaxy() / 2;
 for (i=EMPTY_FILL; i     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,low, high;
 char moderange[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 getmoderange(gd, &low;, &high;); /* get the mode range for this driver */
 sprintf(moderange, "This driver supports modes %d..%d", low, high); 
/* convert mode range info. into strings */
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2, getmaxy() / 2, moderange);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 char palettesize[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 sprintf(palettesize, "The palette has %d modifiable entries.",getpalettesize()); 
/* convert palette size info into string */
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 outtextxy(getmaxx() / 2, getmaxy() / 2, palettesize);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,i,j = 10,height;
 struct palettetype pal;
 char palettesize[80], paletteval[20];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 getpalette(&pal;); /* grab a copy of the palette */
 sprintf(palettesize, "The palette has %d modifiable entries.",pal.size);
 /* convert palette info into strings */
 outtextxy(getmaxx()/2-175, j, palettesize);
 if (pal.size != 0)
 {
 height = textheight("l");
 j += 2*height;
 outtextxy(getmaxx()/2-125, j, "Here are the current values:");
 j += 2*height;
 for (i=0; i     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
char *clip[] = { "OFF", "ON" };
int main()
 {
 int gd=DETECT,gm,error, midx, midy, ht;
 struct viewporttype viewinfo;
 char topstr[80], botstr[80], clipstr[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk)
 {
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 midx = getmaxx() / 2;
 midy = getmaxy() / 2;
 getviewsettings(&viewinfo;); /* get information about current viewport */
 sprintf(topstr, "(%d, %d) is the upper left viewport corner.",viewinfo.left, viewinfo.top);
 sprintf(botstr, "(%d, %d) is the lower right viewport corner.",viewinfo.right, viewinfo.bottom);
 sprintf(clipstr, "Clipping is turned %s.", clip[viewinfo.clip]);
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 ht = textheight("W");
 outtextxy(midx, midy, topstr);
 outtextxy(midx, midy+2*ht, botstr);
 outtextxy(midx, midy+4*ht, clipstr);
 outtextxy(getmaxx()-150,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,i;
 char msg[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 moveto(getmaxx() / 2, getmaxy() / 2); /* move to the screen center point */
 sprintf(msg, "<-(%d, %d) is the here.", getx(), gety());
 outtext(msg);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 char msg[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 moveto(getmaxx() / 2-100, getmaxy() / 2+25); /* move to the screen center point */
 sprintf(msg, "<-(%d, %d) is the here.", getx(), gety());
 outtext(msg);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setlinestyle(DOTTED_LINE, 0, 3);
 rectangle(10, 10, getmaxx()-10,getmaxy()-10);
 outtextxy(getmaxx()/2-100, getmaxx()/3, "Before default values are restored.");
 outtextxy(getmaxx()-250,getmaxy()-30,"www.CProgrammingExpert.com");
 getch();
 graphdefaults(); /* restore default values for everything */
 cleardevice();
 rectangle(10, 10, getmaxx()-10,getmaxy()-10);
 /* output rectangle with default settings */
 outtextxy(getmaxx()/2-100, getmaxy()/3, "After restoring default values.");
 outtextxy(getmaxx()-250,getmaxy()-30,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#define NONSENSE -50
int main()
 {
 int gd=NONSENSE,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error: %s\n", grapherrormsg(error));
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 rectangle(10, 10, getmaxx()-10,getmaxy()-10);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#define ARROW_SIZE 10
void draw_arrow(int x, int y);
int main()
 {
 int gd=DETECT,gm,error,i;
 void *arrow;
 int x, y, maxx;
 unsigned int size;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 maxx = getmaxx();
 x = 0;
 y = getmaxy() / 2;
 draw_arrow(x, y); /* draw the image to be grabbed */
 size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE);
 /* calculate the size of the image */
 arrow = malloc(size); /* allocate memory to hold the image */
 getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow);
 /* grab the image */
 while (!kbhit()) /* repeat until a key is pressed */
 {
 putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); /* erase old image */
 x += ARROW_SIZE;
 if (x >= maxx)
 x = 0;
 putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); /* plot new image */
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 }
 free(arrow);
 closegraph();
 return 0;
}


void draw_arrow(int x, int y)
 {
 moveto(x, y); /* draw an arrow on the screen */
 linerel(4*ARROW_SIZE, 0);
 linerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
 linerel(0, 2*ARROW_SIZE);
 linerel(2*ARROW_SIZE, -1*ARROW_SIZE);
 }

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 char message[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 moveto(100,100); /* move the CP to location (100,100) */
 sprintf(message, " (%d, %d)", getx(), gety()); 
/* create and output a message at (100,100) */
 outtextxy(100,100, message);
 linerel(200, 200);
 /* draw line to a point a relative distance away from current CP*/
 sprintf(message, " (%d, %d)", getx(), gety());
 /* create and output a message at CP */
 outtext(message);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error;
 char msg[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 moveto(100, 100); /* move the CP to location (100,100) */
 sprintf(msg, " (%d, %d)", getx(), gety()); /* create and output a message at (100,100) */
 outtextxy(100,100, msg);
 lineto(200, 200); /* draw a line to (100,100) */
 sprintf(msg, " (%d, %d)", getx(), gety()); /* create and output a message at CP */
 outtext(msg);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
/* moverel example */
int main()
 {
 int gd=DETECT,gm,error;
 char msg[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 moveto(100,100);
 putpixel(getx(), gety(), getmaxcolor()); /* plot a pixel at the CP */
 sprintf(msg, " (%d, %d)", getx(), gety());
 outtextxy(100,100, msg);
 moverel(200, 200);
 putpixel(getx(), gety(), getmaxcolor()); /* plot a pixel at the CP */
 sprintf(msg, " (%d, %d)", getx(), gety()); 
/* create and output a message at CP */
 outtext(msg);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     


        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,i;
 char msg[80];
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 moveto(100,100);
 putpixel(getx(), gety(), getmaxcolor());
 sprintf(msg, " (%d, %d)", getx(), gety());
 outtextxy(100,100, msg);
 moveto(200,200);
 putpixel(getx(), gety(), getmaxcolor());
 sprintf(msg, " (%d, %d)", getx(), gety());
 outtext(msg);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
 {
 int gd=DETECT,gm,error,stangle = 45, endangle = 135, radius = 200;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 setfillstyle(EMPTY_FILL, getmaxcolor()); /* set fill style and draw a pie slice */
 pieslice(getmaxx() / 2, getmaxy() / 2, stangle, endangle, radius);
 outtextxy(getmaxx()-250,getmaxy()-20,"www.CProgrammingExpert.com");
 getch();
 closegraph();
 return 0;
}

     



        

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
//outtext
int main()
 {
 int gd=DETECT,gm,error;
 initgraph(&gd;,&gm;,"f:\\tc\\bgi");
 error = graphresult();
 if (error != grOk) 
 { 
 printf("Graphics error occurred");
 printf("Press any key to halt:");
 getch();
 exit(1);
 }
 setbkcolor(BLUE);
 for (i=SOLID_FILL; i     

Home

Goto statement

The goto statement is used to alter the normal sequence of program execution by transferring control to some other part of the program unconditionally. In its general form, the goto statement is written as

goto label;

                   where the label is an identifier that is used to label the target statement to which the control is transferred. Control may be transferred to anywhere within the current function. The target statement must be labeled, and a colon must follow the label. Thus the target statement will appear as

label:statement;

Each labeled statement within the function must have a unique label, i.e., no two statement can have the same label.

The following program illustrates the use of  goto statement.

Home

String

 

                        A string in C is actually a character array. As an individual character variable can store only one character, we need an array of characters to store strings. Thus, in C string is stored in an array of characters. Each character in a string occupies one location in an array. The null character ‘\0’ is put after the last character. This is done so that program can tell when the end of the string has been reached. For example, the string ”I Like C Programming” is stored as follows.

I   L i k e   C   P r o g r a m m i n g \o

Since the string has 20 characters (including space), it requires an arrayof at least, size 21 to store it.

                       Thus, in C, a string is a one-dimensional array of characters terminated a null character. The terminating null character is important. In fact, a string not terminated by ‘\0’ is not really a string, but merely a collection of characters.

                      A string may contain any character, including special control characters, such as \n\t\\ etc…

                      There is an important distinction between a string and a single character in C. The convention is that single characters are enclosed by single quotes e.g. ‘*’ and have the type char. Strings, on the hand, are enclosed by double quotes e.g. “name” and have the type “pointer to char” (char *) or array of char.

                      Strings can be declared in two main ways; one of these is as an array of characters, the other is as a pointer to some pre-assigned array. Perhaps the simplest way of seeing how C stores arrays is to give an extreme example which would probably never be used in practice.

#include<stdio.h>
int main ()
       {
       char string[];
       string[0] = ‘C’;
       string[1] = ‘P’;
       string[2] = ‘r’;
       string[3] = ‘o’;
       string[4] = ‘g’;
       string[5] = ‘r’;
       string[6] = ‘a’;
       string[7] = ‘m’;
       string[8] = ‘m’;
       string[9] = ‘i’;
       string[10]= ‘n’;
       string[11] = ‘g’;
       printf (“%s”, string);
       return 0;
      }

                          This method of handling strings is perfectly acceptable, if there is time to waste, but it is so laborious that C provides a special initialization service for strings, which bypasses the need to assign every single character with a new assignment!.

The other way is use a pointer to some pre-assigned array.

#include<stdio.h>
int main ()
      {
      char str1[]=”I Like”;
      char *str2=”C Programming”;
      puts(str1);
      puts(str2);
      return 0;
}
Home

IO Functions

The usually used input statement is scanf () function.

Syntax of scanf function is
                  scanf (“format string”, argument list);

                The format string must be a text enclosed in double quotes. It contains the information for interpreting the entire data for connecting it into internal representation in memory.
Example: integer (%d) , float (%f) , character (%c) or string (%s).

                The argument list contains a list of variables each preceded by the address list and separated by comma. The number of argument is not fixed; however corresponding to each argument there should be a format specifier. Inside the format string the number of argument should tally with the number of format specifier.

               Example: if i is an integer and j is a floating point number, to input these two numbers we may use
scanf (“%d%f”, &i, &j);

Program:

Home

SEO Expert india (local services)

Dear Internet friend,
Are you looking for an seo expert india ?
Are you looking for someone to help your seo work?
Do you need more traffic to your website?
Do you want to make more money from your website by getting more traffic?
Do you want to earn more Adsense revenue? If ‘Yes’ I can help you.

Home