Question

Please Print out a Pattern: British Flag (x cross pattern and t shape pattern in "...

Please Print out a Pattern: British Flag (x cross pattern and t shape pattern in " * " in c++ code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/****************************************flag.cpp*********************/


#include <iostream>

using namespace std;

int main()
{
  
   //print upper border
for ( int i = 0; i <= 108; i++ ){
       cout << "*";
   }
cout << endl;

for ( int i = 0; i < 12; i++ )
{
   //print left upper border
       cout << "*";
   for ( int j = 0; j < 4*( i+1); j++ ) {
           cout << " ";
       }
       //print upper left part of half x
   cout << "*";
   for ( int j = 0; j < 4*(12 -i); j++ ){
           cout << " ";
       }
       //print upper T
   cout <<"*";
   for ( int j = 0; j < 4*(12-i); j++ ){
           cout << " ";
       }
       //print upper right part of half x
   cout <<"*";
   for ( int j = 0; j < 4*(i+1); j++ ){
           cout << " ";
       }
       //print right upper vertical border
   cout<<"*";
   cout << endl;
}

//print middle Horizontal line
for ( int i = 0; i <= 108; i++ ){
       cout << "*";
   }
cout << endl;
    //print the lower x and T part  
for ( int i = 0; i < 12; i++ )
{
   cout << "*";
   for ( int j = 0; j < 4*( 12-i); j++ ){
           cout << " ";
       }
   cout << "*";
   for ( int j = 0; j < 4*(i+1); j++ ){
      
          cout << " ";
       }
   cout<<"*";
   for ( int j = 0; j < 4*(i+1); j++ ) {
           cout << " ";
       }
   cout<<"*";
for ( int j = 0; j < 4*( 12-i); j++ ){
           cout << " ";
       }
   cout <<"*";
   cout << endl;
}
    //print lower border
for ( int i = 0; i <= 108; i++ ){
       cout << "*";
   }

cout << endl;

return 0;
}

/***************output******************/

*************************************************************************************************************
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
*************************************************************************************************************
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
*************************************************************************************************************

Please let me know if you have any doubt or modify the answer, Thanks:)

Add a comment
Know the answer?
Add Answer to:
Please Print out a Pattern: British Flag (x cross pattern and t shape pattern in "...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MATLAB Write segment of code using nested for loops to print out the following pattern. Your...

    MATLAB Write segment of code using nested for loops to print out the following pattern. Your segments of code should prompt the user for a positive integer, n, and print the following star pattern depending on n. An equilateral triangle. Pictured below is case n = 6. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *...

  • Design (pseudocode)(name it Pattern) that uses nested loops to print out the following pattern. Document your...

    Design (pseudocode)(name it Pattern) that uses nested loops to print out the following pattern. Document your code properly. 1 2 3 4 5 6 1 2 3 4 5     1 2 3 4       1 2 3         1 2           1

  • please write c programming for this code below. Write a program to print a pattern of...

    please write c programming for this code below. Write a program to print a pattern of numbers separated by spaces for the given number of rows. At the time of execution, the program should print the message on the console as: Enter number of rows For example, if the user gives the input as: Enter number of rows : 4 then the program should print the result as: 232 34543 4567654

  • Not yet answered Marked out of 1.00 Flag question Question text What is the value of...

    Not yet answered Marked out of 1.00 Flag question Question text What is the value of the following Python expression? not(True and False) Select one: True False Question 2 Not yet answered Marked out of 1.00 Flag question Question text Consider the following Python program. fin = open('words.txt') for line in fin: word = line.strip() print(word) What does the program loop over? Select one: a. Lines in a file b. Lines in a list c. Words in a dictionary d....

  • Question 7 Not yet answered Marked out of 2.00 Flag question The cross section dimensions of...

    Question 7 Not yet answered Marked out of 2.00 Flag question The cross section dimensions of a metal rod is (0.007 m x 0.007 m), its length is 1000 mm. The allowable stress is 200 MPa. An axial force (longitudinal force) is applied to this rod. 1. The force changes the section dimension to be (0.006 mx 0.006 m), so the type of this force is 2. Due to this change in section dimensions, the new length will be

  • Write a Python program (using a nested loop) to print out the following pattern (there is...

    Write a Python program (using a nested loop) to print out the following pattern (there is a space between the numbers next to each other). 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1

  • QUESTION 1 If the cross section of the beam in the previous question is "T" shape...

    QUESTION 1 If the cross section of the beam in the previous question is "T" shape with the below dimensions, find the centroid and moment of inertia of the complex shape by constructing the table, do the required calculations and answer the following questions. TFw TFIT BFt BFw TFw= 80mm TFt= 38.4mm Wh= 50mm Wt= 10mm BFt= 32mm BFw= 100mm The y-coordinate of the centroid of the complex "I" shape =

  • - Write a C code, create a child process, and print out process IDs. Please ubuntu...

    - Write a C code, create a child process, and print out process IDs. Please ubuntu gcc compiler Thank you..

  • 5) Find the moment M, if the maximum tensile stress in the T shape cross section...

    5) Find the moment M, if the maximum tensile stress in the T shape cross section js 1 ksi. Determine the maximum compressive stress. 7) a-a is 10 in wide and 6 in deep. Determine maximum tensile and comoressive stress on a-a Find the moment M, if the maximum tensile stress in the T-shape cross section is 1ksi. Determine the maximum compressive stress. 2 in 10 in 2 in 4 in -1 in 1 inz 2 in 11 in 2...

  • Question 19 Tries remaining: 4 Points out of 1.00 P Flag question The position of a...

    Question 19 Tries remaining: 4 Points out of 1.00 P Flag question The position of a 0.30-kg object attached to a spring is described by x(0.21 m) cos[(0.7n rad/s) q. (Assume tis in seconds.) X= (a) Find the amplitude of the motion. Answer: Check Question 20 Tries remaining: 4 Points out of 1.00 P Flag question (b) Find the spring constant. Answer: Check Question 21 Tries remaining 4 Points out of 1.00 P Flag question (c) Find the position of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT