C++ PROGRAM TO PRINT ALPHABET TRIANGLE!!!

|ALPHABET TRIANGLE|

There are different triangles that can be printed. Triangles can be generated by alphabets or numbers.

In this C++ program, we are going to print alphabet triangles.

  • Let’s start the program with the header file

“#include<iostream>” →Input-output continuous bytes of data.

“using namespace std;” →used to store variable name.

“int main()” →returns datatype function.”

“{ char ch=’A’;
int i, j, k, m;
for(i=1;i<=5;i++)”

  • In char we have given (ch=A). And we have declared four variables (i,j,k,m) are defined in integer.

char →data type used for the storage of letter

int → data type used to store integer (numbers)

“ { for(j=5;j>=i;j- -)
cout<<” “;
for(k=1;k<=i;k++)
cout<<ch++;
ch- -;
for(m=1;m<i;m++)
cout<- -ch;
cout<<”\n”;
ch=’A’;
}
return 0; }”

FOR LOOP:

When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop:

Syntax

for (statement 1; statement 2; statement 3) {
// code block to be executed
}

Statement 1 is executed (one time) before the execution of the code block.

Statement 2 defines the condition for executing the code block.

Statement 3 is executed (every time) after the code block has been executed.

return 0 →which means the program is executed successfully.

SOURCE CODE:

OUTPUT:

--

--

--

Studying B.TECH(IT) at VCET Madurai.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

New updates!

Common Kubernetes Errors Made by Beginners [2022]

common kubernetes errors or mistakes

Ever — Open-Source On-Demand Commerce Platform

Datadog — Azure API Management logs

Design Patterns

Legacy Application Modernization: Benefits and Risks of Moving to the Cloud

8 tips & tactics how to quickly onboard developers to a new project

3 macOS Quirks for New Users to Get Used To

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gomathi Keerthana.R.S.

Gomathi Keerthana.R.S.

Studying B.TECH(IT) at VCET Madurai.

More from Medium

Core memory making: Food Edition

Dual-Booting Encrypted Windows 10 and Elementary OS 6 on UEFI-Enabled Systems

Enhance Workplace Productivity with individuals driven drives

Lippia Test Automation