Preview:
#include <iostream>
#include<iomanip>
using namespace std;
int main() {
int num;
cout<<"enter a number";
cin>>num;
for(int r=1;r<=num;r++){
      for(int s=0;s<=r-1;s++){
          cout<<' ';}
          
          for(int c=1;c<=2*num-2*r+1;c++){
             if(r==1){cout<<'*';}
             else if(c==r || c==2*num-2*r+1){cout<<'*';}
              else {cout<<' ';}
          }      
    cout<<endl;                
    
}  
    

          

  
    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter