Question

You are currently redecorating your apartment. You love Computer Science so much that you've decided to...

You are currently redecorating your apartment. You love Computer Science so much that you've decided to create a rug that displays ASCII characters. You are not sure, however, what character or how big you want the rug! Help yourself out by creating a program that will:

Input a width and height for the size of the rug (between 1 and 50 inclusive).

Input a character to test on the rug (assume only one character will be given).

Output a mock up of the rug, using the dimension and character specified by the user.

Each character should be printed with a space after it. You can assume the input to your program is always valid (e.g., a negative number will not be entered for the width).

Example Execution #1

Input the dimensions for the rug, and the character to print:
WIDTH> 7
HEIGHT> 5
CHARACTER> *
A 7x5 rug with character * will look like:
OUTPUT * * * * * * *
OUTPUT * * * * * * *
OUTPUT * * * * * * *
OUTPUT * * * * * * *
OUTPUT * * * * * * *

0 0
Add a comment Improve this question Transcribed image text
Answer #1
//c++ program to make a pattern that take input from the user 
#include<bits/stdc++.h>
using namespace std;
//main function start
int main(){
        int width,height;           
        cout<<"enter the width"<<endl;
        cin>>width;                                                //taking input of width from the user 
        cout<<"enter the height "<<endl; 
        cin>>height;                //taking input of height from the user 
        char ch;
        cout<<"enter the character you want to make pattern"<<endl;
        cin>>ch;                                 //taking input of char of whcich you have to mkae pattern
        //first loop id for height 
        for(int i=0;i<height;i++){
                //second loop is for the printing the width 
                for(int j=0;j<width;j++){
                        cout<<ch<<" ";
                }
                //after each linear printing the next row in next coloumn
                cout<<endl;
        }
}

here output screen :

the size of the rug is 7x5.D:\dsa and algo practice.exe enter the width enter the height enter the charcter you want to make pattern 7 5 * * * * * * **if you have any problem then feel free to ask in comment section.

Add a comment
Know the answer?
Add Answer to:
You are currently redecorating your apartment. You love Computer Science so much that you've decided to...
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
  • C++ please! In this program you will be outputting the characters that map to the ASCIl...

    C++ please! In this program you will be outputting the characters that map to the ASCIl codes 32 through 126. You will need a loop to iterate through the input values and output the corresponding character. This mapping is shown in appendix A in your Gaddis text book. Your program will be reading in two unsigned integer values. The prompt for read will be Enter lower and upper values You need to check that both values are in the range...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D....

    Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D. Decryption Implement two decryption functions corresponding to the above ciphers. When decrypting ciphertext, ensure that the produced decrypted string is equal to the original plaintext: decryptCaesar(ciphertext, rshift) == plaintext decryptVigenere(ciphertext, keyword) == plaintext Write a program decryption.cpp that uses the above functions to demonstrate encryption and decryption for both ciphers. It should first ask the user to input plaintext, then ask for a right...

  • Stuck on this computer science assignment Write a program that demonstrates binary searching through an array...

    Stuck on this computer science assignment Write a program that demonstrates binary searching through an array of strings and finding specific values in an corresponding parallel double array. In all cases your output should exactly match the provided solution.o. Provided files: Assignment.cpp - starter assignment with function prototypes companies.txt - file for program to read. earnings.txt - file for program to read. Input1.txt Input2.txt - Test these inputs out manually, or use stream redirection Input3.txt - These inputs are based...

  • 6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you...

    6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you will practice working with arrays. Your program will read lines of text from the keyboard and use an array to track the number of times each letter occurs in the input text. You will use the contents of this array to generate a histogram (bar graph) indicating the relative frequencies of each letter entered. Test cases are available in this document. Remember, in addition...

  • Hello Guys. I need help with this its in java In this project you will implement...

    Hello Guys. I need help with this its in java In this project you will implement a Java program that will print several shapes and patterns according to uses input. This program will allow the use to select the type (say, rectangle, triangle, or diamond), the size and the fill character for a shape. All operations will be performed based on the user input which will respond to a dynamic menu that will be presented. Specifically, the menu will guide...

  • please answer all question CSE 110 Introduction to Computer Science 41. An array of size 10,...

    please answer all question CSE 110 Introduction to Computer Science 41. An array of size 10, has only nine slots for storing values TRUE FALSE 42. When is the external name of the file used in the program? A. Any time you read or write to the file B. Never C. Only when reading from the file D. When opening the file stream 43. Creating a flow chart when designing a complex algorithm is a waste of time. TRUE 44....

  • Banks issue credit cards with 16 digit numbers. If you've never thought about it before you...

    Banks issue credit cards with 16 digit numbers. If you've never thought about it before you may not realize it, but there are specific rules for what those numbers can be. For example, the first few digits of the number tell you what kind of card it is - all Visa cards start with 4, MasterCard numbers start with 51 through 55, American Express starts with 34 or 37, etc. Automated systems can use this number to tell which company...

  • You are going to be implementing the classic computer science simulation, Conway's Game of Life. Conway's...

    You are going to be implementing the classic computer science simulation, Conway's Game of Life. Conway's Life is played on a matrix of cells, kind of like a chess board but theoretically extending infinitely in every direction. Each individual cell in the matrix can either be alive or dead. A live cell in the matrix is shown in our simulation by printing an asterisk (*) to the screen. A dead cell is shown by leaving that area of the matrix...

  • **JAVA PLEASE!!** CSE205 Assignment 2 ASCII Terrain Generator 5Opts Topics: Arrays Multidimensional Arrays Metho...

    **JAVA PLEASE!!** CSE205 Assignment 2 ASCII Terrain Generator 5Opts Topics: Arrays Multidimensional Arrays Methods Loops and Conditionals Description The goal of this assignment is for you to produce a simple procedurally generated terrain map out of ASCII character symbols. This will be done through simple probability distributions and arrays Use the following Guideline s: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc) Keep identifiers to a reasonably short length. User upper case for constants....

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
ADVERTISEMENT