Question

Write a C++ program that 1. Prompt user to enter two integer a and b. 2....

Write a C++ program that
1. Prompt user to enter two integer a and b.
2. Then prints a b rows each of which contains a * b columns of Xs, but after each group of b complete columns the program prints a| symbol (35 pts)
An example run of the program follows.
a=3, b = 5
XXXXX|XXXXX|XXXXX|
XXXXX|XXXXX|XXXXX|
XXXXX|XXXXX|XXXXX|
XXXXX|XXXXX|XXXXX|
XXXXX|XXXXX|XXXXX|
XXXXX|XXXXX|XXXXX|
XXXXX|XXXXX|XXXXX|
XXXXX|XXXXX|XXXXX|

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

CODE :

4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 HNM in 0 0 Nm x_pattern.cpp #include<iostream> using namespace std; int main() { int

OUTPUT :

jeswaanth@boolean-beast:-/Desktop$ 9++ -o out x_pattern.cpp jeswaanth@boolean-beast:-/Desktop$ ./out Enter value of a:3 Enter

Raw_Code :

#include<iostream>
using namespace std;
int main(){
   int a,b;
   cout<<"Enter value of a:";       //taking a and b as inputs
   cin>>a;
   cout<<"Enter value of b:";
   cin>>b;
   for(int i=0;i<a+b;i++){ //loop to print rows
       for(int j=1;j<=a*b;j++){   //loop to print columns
           cout<<"X";
           if(j%b==0){               //if it's after group of b then
               cout<<"|";
           }
       }
       cout<<"\n";       //printing newline after each row
   }
}

**********Comment me for any Queries and Rate me up**************

Add a comment
Know the answer?
Add Answer to:
Write a C++ program that 1. Prompt user to enter two integer a and b. 2....
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
  • Write a program which prompts the user to enter a number of rows, and prints a...

    Write a program which prompts the user to enter a number of rows, and prints a hollow square star pattern with 2 diagonals. Note: you can assume that the integer will always be > 1 and will be an odd number. For example: Input Result 5 Enter number of rows: 5 ***** ** ** * * * ** ** ***** 9 Enter number of rows: 9 ** ** ** * * * * * * * * * * **...

  • Write a Java program that performs these operations Prompt the user to enter a low height...

    Write a Java program that performs these operations Prompt the user to enter a low height in feet (an integer) Prompt the user to enter a high height in feet (an integer) Prompt the user to enter a low weight in pounds (an integer) Prompt the user to enter a high weight in pounds (an integer) Print a table of Body Mass Index (BMI) for the heights and weights entered, ranging from the low height to the high height (inclusive),...

  • 2. Write a C++ program that asks the user to enter a integer between 1 and...

    2. Write a C++ program that asks the user to enter a integer between 1 and 10. Continue to prompt the user while the value entered does not fall within the range. When the user is successful display a congratulatory message. Save file as OneToTen.

  • Write a Python program to prompt the user for an integer number. Assign this integer to...

    Write a Python program to prompt the user for an integer number. Assign this integer to a variable X. Then assign a variable Y to the X**3 (X to the power 3). Finally, assign the variable Z to the square root of Y and print the values of X, Y, and Z as shown in the example below. Use main() function to define and call the program. Example: Enter an integer number: 3 X = 3 if Y=X**3 then Y...

  • Please help!! I need help with C++ and im using the program Atom. Q6 Write a...

    Please help!! I need help with C++ and im using the program Atom. Q6 Write a complete C++ program that does the following. 1. It asks the user to enter positive integers a and b that are each at most 100. 2. The 3. The program determines and prints the maximum entry in each column of the table. 4. The program then prints the smallest value among these maximum entries. For example, the following represents one run of the program....

  • Page > of 2 0 Write algorithm for a program that will prompt user to enter...

    Write algorithm for a program that will prompt user to enter x and y coordinates of two points : (x1, y1) and (x2, y2) the calculate the distance between these two points. For example, if the two points are as shown below, then distance d can be evaluated using the formula below. Formula for this distance d is:Submit printout - with your name on top. Question 2 Implement the algorithm above in Java Submit printout of source code - with your name on top. Also...

  • Write a C++ program that prompts the user to enter two numbers. Then prompt the user...

    Write a C++ program that prompts the user to enter two numbers. Then prompt the user to select from the following options: a. Add the numbers. b. Multiply the numbers. c. Terminate the program Use the appropriate control structures (loops, if else, switch-case, etc) to make your program as short and efficient as possible. Minor syntax errors are forgiven in this exercise; just focus on the correct structure, declarations and sequence of instructions

  • please solve using python thank you! Write a program which prompts the user to enter a...

    please solve using python thank you! Write a program which prompts the user to enter a number of rows, and prints a hollow square star pattern with 2 diagonals. Note: you can assume that the integer will always be > 1 and will be an odd number. For example: Input Result 5 Enter number of rows: 5 ***** ** ** * * * ** ** ***** 9 Enter number of rows: 9 ** ** ** * * * * *...

  • Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display...

    Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display the numbers in 3 formats. Then check, whether the larger of the 2 is evenly divisible by the smaller. Detail: Write a complete C program, more complex than the typical "hello world" program. Prompt the user to enter 2 integer numbers that are not negative. After either entry, display that number again. Print the smaller in hexadecimal, in decimal, and in octal format. Include...

  • C++ please Problem 3: Write a C++ program that prompts the user to enter an integer...

    C++ please Problem 3: Write a C++ program that prompts the user to enter an integer of any length (but not more than 8- digits), the program then extracts and prints each digit in its respective column. For example, in the integer 436, 4 should be printed in the 4th column, 3 in the 3rd and 6 in the 6th column. Hint: you can use setw to solve this problem. Sample Input/Output Enter an integer of any length. 9836472 ...Printing...

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