Below code will print the asterisk pyramid upto 5 level

in the above program we are initializing three loops,…