Customizable training materials to learn C++

Looking for C++ Tutorial Visit Nano teach c++!
  • C++ Tutorial
    16/07/2014 - 0 Comments
    This tutorial series will help you to get started in C++ to develop system applications.   C++ Example: /* * File: main.cpp * Author: Nano * Just click…
  • C++ Loops, Creating a Pyramid
    05/07/2014 - 0 Comments
    C++ program to create a pyramid using for loop and if condition. Example: #include<iostream> using namespace std; int main() { int i,j,k,space=10; // to print the…
Nano teach C++ found result for your search here:

C++ Loops, Creating a Pyramid

C++ program to create a pyramid using for loop and if condition.
Example:
#include<iostream>
using namespace std;

int main()
{
   int i,j,k,space=10; // to print the pyramid in center, you can also increase the # of spaces
   
for (int i=0;i<=5;i++)
{
   for (int k=0;k<space;k++)
{
   cout<<" ";
}
for (int j=0;j<2*i-1;j++)
{
   cout<<"*";
}
   space--;
   cout<<endl;
}
cin.get(); /*use this to wait for a keypress*/

} 
 















Program Output:
         *
        ***
       *****
      *******
     *********

No comments:

Post a Comment