Software Development Exam  >  Software Development Notes  >  Basics of C++  >  Code: Incremental Alphabets

Code: Incremental Alphabets | Basics of C++ - Software Development PDF Download

Code: Incremental Alphabets | Basics of C++ - Software Development

C++ Program for printing 6 different Triangle/Half Pyramid Programs with Incremental Numbers

#include<iostream>


using namespace std;


void halfPyramidAlphabets1(int n) {

  char alphabet = 'a';

  for (int i = 1; i <= n; i++) {

    for (int j = 1; j <= i; j++) {

      cout << alphabet;

    }

    alphabet++;

    cout << endl;


  }

}

void halfPyramidAlphabets2(int n) {

  char alphabet = 'a';

  for (int i = n; i > 0; i--) {

    for (int j = 1; j <= i; j++) {

      cout << alphabet;

    }

    cout << endl;

    alphabet++;

  }

}


void halfPyramidAlphabets3(int n) {

  char alphabet = 'a';

  for (int i = 1; i <= n; i++) {

    for (int k = n - i; k > 0; k--)

      cout << " ";

    for (int j = 1; j <= i; j++) {

      cout << alphabet;

    }

    cout << endl;

    alphabet++;

  }

}


void halfPyramidAlphabets4(int n) {

  char alphabet = 'a';

  for (int i = n; i > 0; i--) {

    for (int k = n - i; k > 0; k--)

      cout << " ";

    for (int j = 1; j <= i; j++) {

      cout << alphabet;

    }

    cout << endl;

    alphabet++;

  }

}

void halfPyramidAlphabets5(int n) {


  for (int i = 1; i <= n; i++) {

    char alphabet = 'a';

    for (int j = 1; j <= i; j++) {

      cout << alphabet++;

    }

    cout << endl;

  }

}


void halfPyramidAlphabets6(int n) {

  char alphabet = 'a';

  for (int i = 1; i <= n; i++) {

    for (int j = 1; j <= i; j++) {

      cout << alphabet++;

    }

    cout << endl;

  }

}


int main() {

  int num;

  cout << "Enter number of levels of the pattern :" << endl;

  cin >> num;

  halfPyramidAlphabets1(num);

  cout << endl;

  halfPyramidAlphabets2(num);

  cout << endl;

  halfPyramidAlphabets3(num);

  cout << endl;

  halfPyramidAlphabets4(num);

  cout << endl;

  halfPyramidAlphabets5(num);

  cout << endl;

  halfPyramidAlphabets6(num);


  return 0;

}

The document Code: Incremental Alphabets | Basics of C++ - Software Development is a part of the Software Development Course Basics of C++.
All you need of Software Development at this link: Software Development
70 videos|45 docs|15 tests

Top Courses for Software Development

70 videos|45 docs|15 tests
Download as PDF
Explore Courses for Software Development exam

Top Courses for Software Development

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Semester Notes

,

MCQs

,

shortcuts and tricks

,

past year papers

,

Previous Year Questions with Solutions

,

practice quizzes

,

Code: Incremental Alphabets | Basics of C++ - Software Development

,

Extra Questions

,

Exam

,

ppt

,

Code: Incremental Alphabets | Basics of C++ - Software Development

,

Summary

,

Objective type Questions

,

Viva Questions

,

study material

,

Code: Incremental Alphabets | Basics of C++ - Software Development

,

video lectures

,

Sample Paper

,

Free

,

pdf

,

mock tests for examination

,

Important questions

;