Question

Please upload.cpp file only before the time up. The code must contain your name and has proper format. No library function is
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream> using namespace std; void pyramid( int n){ int i,j; for(i 0; i<n; i++) { X IB for(j = 0; j < (2 * n); j++Enter a number 3 or more than 3 : 3 XXX x x x X X XXEnter a number 3 or more than 3 : 4 x x x x x Χ Χ Χ Χ Χ x x x x Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ XEnter a number 3 or more than 3 : 7 x x x x x x x Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ x x x x x x Χ Χ Χ Χ Χ x x x x x Χ Χ Χ Χ Χ Χ Χ Χ xEnter a number 3 or more than 3 : 2 pelase try again!Enter a number 3 or more than 3 : 1 pelase try again!

#include <iostream>
using namespace std;
void pyramid( int n)
{ int i,j;
for(i = 0; i < n; i++)
{
for(j = 0; j < (2 * n); j++)
{
if(i + j <= n - 1)  
cout << "x";
else
cout << " ";
if((i + n) <= j)  
cout << "x";
else
cout << " ";
}
cout << "\n";
}
}
int main()
{

int i, j, n;
cout<<"Enter a number 3 or more than 3 : ";
cin >> n;
  
if(n<=2)
{
cout<<"pelase try again!";
exit(0);
}
else if(n%2==0)
{
n=n+1;
pyramid(n);
}
else
pyramid(n);
  
  
return 0;
}

If there is any queries please mention in comment. Thank you

Please give me a life for my efforts.

Add a comment
Know the answer?
Add Answer to:
Please upload.cpp file only before the time up. The code must contain your name and has...
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
  • Having trouble coding this for C++. Please add comments for better understanding! Write a program that...

    Having trouble coding this for C++. Please add comments for better understanding! Write a program that draws two triangles by using a character 'X' as examples below. The program must prompts a user for an integer larger than 2. The user input will then be used to set the size of the output. If a user input an even value, the program will increase it by one before drawing the box. Example 1: Input: 3 Output: XXX XXX XX XX...

  • 12 pts Please upload.cpp file only before the time up. The code must contain your name...

    12 pts Please upload.cpp file only before the time up. The code must contain your name and has proper format. Write a program that prompts a user to enter a line of text (including whitespace). Please use string object NOT e-string, a string library can be included. 1. Convert the input into uppercase and output the string to the screen. 2. Get the first and the last characters then appends the line with "I Love C++" and output the string...

  • C++ only Implement a program that prompts a user to enter a number N where N...

    C++ only Implement a program that prompts a user to enter a number N where N is a positive number. The program must validate a user input and ask a user to re-enter until an input is valid. Implement a function that pass N as an argument and return a result of calculates N! (N-factorial): The function must use loop for the implementation. Hint: Factorial: N! = N * (N-1) * (N-2) * …. * 1 ( This is only...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The progra...

    Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...

  • This code should be in C please!! Your file should meet the following criteria: • Function...

    This code should be in C please!! Your file should meet the following criteria: • Function prototype and implementation for a calculateDivisors function that takes in an integer parameter, calculates the sum of its divisors, and returns that sum (as an integer value) • A structure that represents what is represented on each line of output, e.g., o Line number o Sum of the divisors for that line number o Character array containing “Perfect”, “Deficient”, or “Abundant” • Pointer declared...

  • build a phone number from digits entered by your user. Your program will loop until 10...

    build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and 9 inclusively. If so, the digit will be stored as the next number in the...

  • Python. Please attach python file if possible. All Instructions given: General The program must allow a...

    Python. Please attach python file if possible. All Instructions given: General The program must allow a trader to enter in stock's symbol, its current price, and a lucky number (see the validation rules for these inputs below). The program then outputs a recommendation to either buy, sell, or hold the stock. The recommendation is based on whether the current stock price is above, below, or equal to a particular threshold value specific to that stock (see more on the threshold...

  • 1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write...

    1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write a Python program that prompts the user for a sentence, then replaces all the vowels in the sentence with an asterisk: '*' Your program should use/call your isVowel function from Assignment_Ch06-01. You can put the isVowel() function in a separate .py file, without the rest of the Ch06-01 code, and then import it. 6-01 CODE: def isVowel(x):     if x in "aeiouyAEIOUY":         return True     else:...

  • please code in basic c++ program Write a program that uses the following formula: n (ax...

    please code in basic c++ program Write a program that uses the following formula: n (ax - ib) i=1 Your program will prompt the user for the number of iterations for the calculation. input values for n, x, a, b, and c. n must be a positive integer, but x, a, b, and c can be any real numbers. Then it will perform the calculation and output the result. Then, it will ask the user if they would like to...

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