66 935
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #48091 in C++ for ayed

Question #48091



[2] Write a program that displays n depth * pyramid. The value of ā€œnā€ will be input from the user of your program.(n>0)

For example,if n is 4, the program displays



*

* * *

* * * * *

* * * * * * *
Expert's answer
#include <stdlib.h>
#include <iostream>  
#include <stdio.h>
#include <cstdlib>  
using namespace std;
int main()
{
int n; 
int x = 1;
cout<<"Enter the n : ";
cin>>n;
system("cls");
for (int i = 1; i <= n; i++)
{
for (int k = 1; k <= (n-i); k++)
cout << " ";
for (int j = 1; j <= x; j++)
cout<<"*";
cout<<endl;
x+=2;
}
system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions