+ Start a Discussion
apoorva pandeyapoorva pandey 

Can we write apex code to show reverse triangle (pattern)?

Best Answer chosen by apoorva pandey
Purushotham YellankiPurushotham Yellanki
Hi Apoorva,

Try below Code in you Dev Console and see if this is what you are looking for. Basically reverse triangle logic is same in almost all OOP languages, it doesn't matter if it is Java or Apex all we are going to use is for loops!

String revTriangle = '';
Integer x = 1;
Integer y = 1;
for (x = 1; x <= 10; x++)
{
for (y = x; y <= 10; y++)
{
if (y<=x)
revTriangle +='*';
else
revTriangle+='*';
}
revTriangle+='\n';
}   

System.debug('ReverserTriangle: \n' + revTriangle);




Thank you

All Answers

Purushotham YellankiPurushotham Yellanki
Hi Apoorva,

Try below Code in you Dev Console and see if this is what you are looking for. Basically reverse triangle logic is same in almost all OOP languages, it doesn't matter if it is Java or Apex all we are going to use is for loops!

String revTriangle = '';
Integer x = 1;
Integer y = 1;
for (x = 1; x <= 10; x++)
{
for (y = x; y <= 10; y++)
{
if (y<=x)
revTriangle +='*';
else
revTriangle+='*';
}
revTriangle+='\n';
}   

System.debug('ReverserTriangle: \n' + revTriangle);




Thank you
This was selected as the best answer
apoorva pandeyapoorva pandey
Thank you Purushotham. This works!
Fb Status in hindiFb Status in hindi
www.fbstatusinhindi.xyz :-Here you will find content related to all types of Wishes, Quotes & Thoughts, Shayaris, Status & much more. We will try to put all kinds of happiness in your lap.
User-added image

Fb Status hindi https://www.fbstatusinhindi.xyz
Whatsaap Status https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html
Royal Status https://www.fbstatusinhindi.xyz
Attitude status https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html
Gf-Bf Status https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html
Friendship Status https://www.fbstatusinhindi.xyz
Romantic Status https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html
Fastival Status https://www.fbstatusinhindi.xyz
Mohabat Status https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html
Sad Status https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html
Happy Status https://www.fbstatusinhindi.xyz
Shayari Status https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html
Funny Status https://www.fbstatusinhindi.xyz
Good Morning Status https://www.fbstatusinhindi.xyz
Motivational Status https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html
Birthday Status https://www.fbstatusinhindi.xyz
Fb status in hindi (https://www.fbstatusinhindi.xyz/2020/12/650-royal-attitude-status-in-hindi-for_6.html)
Fb Status hindi-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Whatsaap Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Royal Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Attitude status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Gf-Bf Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Friendship Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Romantic Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Fastival Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Mohabat Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Sad Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Happy Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Shayari Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Funny Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Good Morning Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Motivational Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1
Birthday Status-https://www.fbstatusinhindi.xyz/2020/12/sad-status-hindi-for-whatsaap-facebook-instagam.html?m=1

https://www.fbstatusinhindi.xyz
https://www.fbstatusinhindi.xyz
https://www.fbstatusinhindi.xyz
https://www.fbstatusinhindi.xyz
https://www.fbstatusinhindi.xyz
https://www.fbstatusinhindi.xyz
https://www.fbstatusinhindi.xyz
https://www.fbstatusinhindi.xyz
https://www.fbstatusinhindi.xyz
Free jobfindFree jobfind
Free jobfindFree jobfind
DBT Agriculture Bihar (https://dbtagri.com/)
Prashant Singh 214Prashant Singh 214
UP Online Covid Test Report labreports.upcovid19tracks.in (https://www.gorakhpurhindinews.com/online-labreports-upcovid19tracks-in/)
Uttar Pradesh All DM Mobile Number UP All DM Mobile Number  (https://www.gorakhpurhindinews.com/mobile-numbers-of-all-district-magistrates-of-uttar-pradesh/)
PNR Status Kaise Pata Kare (https://www.gorakhpurhindinews.com/pnr-status-kaise-pata-kare/) | PNR Number क्या है | PNR Full Form
गोरखपुर पिन कोड लिस्ट | Gorakhpur Pin Code List (https://www.gorakhpurhindinews.com/gorakhpur-pin-code/)
UP Online Covid Test Report  (https://www.gorakhpurhindinews.com/online-covid-19-test-report-on-website-labreports-upcovid19tracks-in/)
 
shse asetshse aset
How can we use this script for me dynamic hosted website? I'm asking for my wordPress sales courses website you can see here (https://salecourses.com/).