You can start by having a variable storing the length of the base of the pyramid (Base). Then having two variables 'a' and 'b' start with a = b = Base/2.
Then go in to a loop each time increasing b by 1 and decreasing a by 1. Then you can have for loops within this loop outputting a space " " unless the loop index corresponds to 'a' or 'b'. Finally when 'a' = 0 have it output '*' all the way from 'a' to 'b' inclusive.
Note that you can't have an even base it will always be odd.
OUTLINE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int iBaseLength = 6;
int a = (int)(iBaseLength/2.0);
int b = (int)(iBaseLength/2.0);
do{
if(a==0){
////////////////output '*'s all from 'a' through 'b'
}
elseif(a!=b){
///////////////output '*'s only for position 'a' and 'b'
}
else{
///////////////Here there is only the case 'a'='b' and there will only be one '*'
}
a--; ///////////decrement 'a'
b++; //////////// increment 'b'
}while(a >= 0);