Showing posts with label Half pyramid. Show all posts
Showing posts with label Half pyramid. Show all posts

Monday, September 16, 2019

Write a program to print half pyramid / triangle using alphabets

Code

#include <iostream>
using namespace std;
int main()
{
 int i, j;
    char input, alphabet = 'A';
    cout << "Enter the uppercase character you want to print in the last row: ";
    cin >> input;
    for(i = 1; i <= (input-'A'+1); ++i)
    {
        for( j = 1; j <= i; ++j)
        {
            cout << alphabet << " ";
        }
        ++alphabet;
        cout << endl;
    }
    return 0;
}



Output - 



Write a program to print half pyramid / triangle using numbers

Code
#include <iostream>
using namespace std;
int main()
{
      int i, j, k;
      cout<< "Enter a positive number : ";cin>>k;

      for(i=1; i<=k; i++)
    {

              for(j=1; j<=i; j++)
           {
                    cout<< j << " ";
            }
        cout<<endl;
      }



 return 0;
}


Output-






Video - 



Write a C++ program to print half pyramid / triangle using *

Code

#include <iostream>
using namespace std;
int main()
{
         int i, j, k;
         cout<< "Enter a positive number : ";cin>>k;

         for(i=1; i<=k; i++)
     {

               for(j=1; j<=i; j++)
            {
                      cout<< " * ";
             }
         cout<<endl;
      }



 return 0;
}


Output








 Video - 


C++ BLACKJACK

#include <iostream> #include <ctime> #include <stdlib.h> #include <time.h> #include <string> using namesp...