EmSAT Achieve Exam  >  EmSAT Achieve Notes  >  C++ for EmSAT Achieve  >  Code: Incremental Alphabets

Code: Incremental Alphabets | C++ for EmSAT Achieve PDF Download

Code: Incremental Alphabets | C++ for EmSAT Achieve

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 | C++ for EmSAT Achieve is a part of the EmSAT Achieve Course C++ for EmSAT Achieve.
All you need of EmSAT Achieve at this link: EmSAT Achieve
70 videos|45 docs|15 tests

Top Courses for EmSAT Achieve

70 videos|45 docs|15 tests
Download as PDF
Explore Courses for EmSAT Achieve exam

Top Courses for EmSAT Achieve

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

Important questions

,

Free

,

practice quizzes

,

mock tests for examination

,

Exam

,

study material

,

past year papers

,

shortcuts and tricks

,

Semester Notes

,

Summary

,

Code: Incremental Alphabets | C++ for EmSAT Achieve

,

video lectures

,

Previous Year Questions with Solutions

,

Objective type Questions

,

Code: Incremental Alphabets | C++ for EmSAT Achieve

,

Sample Paper

,

MCQs

,

ppt

,

Code: Incremental Alphabets | C++ for EmSAT Achieve

,

Viva Questions

,

Extra Questions

,

pdf

;