How to create shapes in C Language

Asked By 0 points N/A Posted on -
qa-featured

How can I make shapes through coding? Do they also include some specific header files or by using simple header files like

include<iostream>

include< stdio.h>

include< codio.h>

we can create shapes? Also, is it possible to fill those shapes with different colors? If we have to use header files, then please tell me details of those header files?

SHARE
Best Answer by JaySoftCenter
Answered By 0 points N/A #85811

How to create shapes in C Language

qa-featured

First, you have to write a library of graphics then call two functions of Windows API and also to Open GL. Usually, we cannot use graphics in C. If you are using the compiler Turbo C, then you can also use its help (go to help and type "graphics" and open the section of graphics and look for every thing). You can draw circles, rectangles, squares, triangles and many other things and color them by using the "set" function and its sub functions. You can also use key commands to move all your results wherever you want.

You can get some knowledge from this link where you will a find a program based on graphics:

http://www.java2s.com/Code/CSharp/2D-Graphics/DrawingShapes.htm

Best Answer
Best Answer
Answered By 0 points N/A #85812

How to create shapes in C Language

qa-featured

Yes we have to include <iostream.h>

  • The iostream library is an object-oriented library that provides input and output functionality using streams.
  • A stream is an abstraction that represents a device on which input and output operations are performed. A stream can basically be represented as a source or destination of characters of indefinite length.
  • Streams are generally associated with a physical source or destination of characters like a disk file, the keyboard, or the console so the characters gotten or written to/from our abstraction called stream are physically input/output to the physical device. For example, file streams are C++ objects to manipulate and interact with files. Once a file stream is used to open a file, any input or output operation performed on that stream is physically reflected in the file.

See the following codes to show how to create a shape in C:

Hi, The program supplied below can do this:

#include <iostream.h>
void main()
{
int n;
cout<<"Enter The Value Of n:";
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=n;j>i;j–)
cout<<" ";
for(int k=0;k<i;k++)
cout<<" *";
cout<<"n";
}
for(i=n;i>0;i–)
{
for(int j=n;j>i;j–)
cout<<" ";
for(int k=0;k<i;k++)
cout<<" *";
cout<<"n";
}
}

Login/Register to Answer

Related Questions