[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
*
* * *
* * * * *
* * * * * * *
1
Expert's answer
2014-10-22T13:27:24-0400
#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; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment