You need to figure out that such asterisk (or any other figure, including christmass tree - that was my assignment few years ago) consist of "*" and SPACES. All we have to do now is to operate with these *'s and spaces correctly :-)
//if you prefer stdio, just change the cout/cin for printf/scanf etc
#include <iostream>
// you probably don't need this line below
usingnamespace std;
int main()
{
int size;
cout<<"Enter asterisk's size: ";
cin>>size; //asterisk will be slightly different depending on number (even/odd) you enter
for(int i=0;i<size;i++)
{
for(int j=0;j<size;j++)
{
if(j==i || j==(size-1)-i) //we print the *s aslant
{
if(j==(size-1))
cout<<"*"<<"\n"; //last "column" of the figure
else
cout<<"*";
}
elseif(j==(size-1))
cout<<" "<<"\n"; //last "column" of the figure
else
cout<<" ";
}
}
return 0;
}