How to draw a triangle in c++

How do you make a triangle in C++?

C++ Program to print Number Triangle

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int i,j,k,l,n;
  6. cout<<“Enter the Range=”;
  7. cin>>n;
  8. for(i=1;i<=n;i++)

How do you draw a triangle in computer graphics?

Write a C Program to Draw A Triangle

  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<graphics.h>
  4. }

How do you make a rectangle loop in C++?

C++ Program to print box shape using for loop

  1. Program uses for loops only to print box shape.
  2. Symbol used is asterisk (*)
  3. Program prints fixed size box.
  4. To change the size change the values of for loops. C++ Code: #include<iostream> using namespace std; int main() { for(int a=1;a<=10;a++) { cout<<“*”; } cout<<endl; for(int b=1;b<=5;b++) { for(int c=1;c<=1;c++) {

How do you print a pyramid?

Algorithm. Accept the number of rows from the user to form pyramid shape Iterate the loop till the number of rows specified by the user: Display 1 star in the first row Increase the number of stars based on the number of rows.

How do you make Pascal’s Triangle in C++?

The program output is also shown below.

  1. * C++ Program to Print Pascal’s Triangle.
  2. #include<iostream>
  3. using namespace std;
  4. int rows;
  5. cout << “Enter the number of rows : “;
  6. cin >> rows;
  7. for (int i = 0; i < rows; i++)
  8. int val = 1;

How do I print a C++ program?


  1. Write programs called PrintPatternX. cpp (where X from A to D ) to print EACH of the following patterns. Use one ” cout << ” for each line of outputs. End each line by printing an ” endl “. …
  2. Print the above patterns using ONE ” cout << ” statement.
See also:  How to compile with c++11

How do you code a triangle?


A triangle is a plane created by connecting three points. The first two arguments specify the first point, the middle two arguments specify the second point, and the last two arguments specify the third point.

Why we use int gd detect GM?

It tells the compiler that what graphics driver to use or to automatically detect the drive. … graphicsMode : It is a pointer to an integer that specifies the graphics mode to be used. If *gdriver is set to DETECT , then initgraph sets *gmode to the highest resolution available for the detected driver.

How do you draw a rectangle in C++?

void rectangle (int left, int top, int right, int bottom); To create a rectangle, you have to pass the four parameters in this function. The two parameters represent the left and top upper left corner. Similarly, the right bottom parameter represents the lower right corner of the rectangle.

How do you make a diamond loop in C++?

Now to print diamond pattern of stars, use six for loops. The first for loop (outer for loop which contains two for loops. One to print spaces and the second to print stars) is to print pyramid pattern of stars. The second for loop (the second outer for loop which also contains two for loops.

How do I make a for loop in a circle C++?

Use following code you’ll get circle in star patters.

  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. float r;
  6. cout<< ” Enter the Radius”<<endl;
  7. cin>> r;
  8. float pr = 2; // pr is the aspected pixel ratio which is almost equal to 2.
See also:  How to compare two strings in c++

How do you make a heart shape in C++?

  1. #include<iostream> #include<cmath>
  2. using namespace std;
  3. int main()
  4. { double x, y,
  5. size=10; char ch=3;
  6. string message(” Happy Valentine’s Day “); int print_line = 4;
  7. if(message. length() % 2 != 0)
  8. message += ” “;

How do you print Pascal triangle?

Program to print pascal’s triangle

  1. // C program to print pascal’s triangle.
  2. #include.
  3. int main()
  4. {
  5. int rows, coef = 1, space, i, j;
  6. printf(“nEnter the number of rows : “);
  7. scanf(“%d”,&rows);

What is P triangle?

In mathematics, Pascal’s triangle is a triangular array of the binomial coefficients. In much of the Western world, it is named after the French mathematician Blaise Pascal, although other mathematicians studied it centuries before him in India, Persia (Iran), China, Germany, and Italy.

Leave a Comment

Your email address will not be published. Required fields are marked *