#include <iostream>
#include "stdafx.h"
int main()
{
int a;
std::cout<<"Type a: ";
std::cin>>a; //a=5
for(int i=0;i<a;i++)
{
for(int j=0;j<a;j++)
{
if(i==0 || i==a-1) //upper and lower edge all filed with "*"
std::cout<<"*";
elseif(j==0 || j==a-1)
std::cout<<"*"; //the middle edges, most right and most left edge
else
std::cout<<" "; //so the output is *___*; _ = space
}
std::cout<<"\n"; //we go to the next "level"
}
return 0;
}
This should produce output like this:
1 2 3 4 5
*****
* *
* *
* *
*****
And as hamsterman pointed out ... at first try to do something by yourself, bring some (not-working) code here etc
I'm newbie at c++ too and many kind people here aready helped me several times, but the forum is the last place i go if i have any problem with my program :)