can anyoune help me to check my code?

#include <iostream>
using namespace std;
int main() {

int side;
int row;
int size;

cout<< "Please enter a number";
cin >> side;

size=side;

while(side>0)
{
row= size;

while (row > 0){

if(size == side){
cout <<"@";
}
else if (side == 1){
cout <<"@";
}
else if (row == 1){
cout << "@";
}
else if (row == size){
cout <<"@";
}
else
{
cout<<" ";
}

--row;
}
cout <<"\n";
--side;
}
return 0;
}
my output suppose is :
@@@@
@ @
@ @
@@@@



Last edited on
You don't say what your code is supposed to do, so it's hard to say if it's right.

Your code does compile and appears to draw a box of a specified positive size.
It handles invalid cases (0, negative number) by not doing anything.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Topic archived. No new replies allowed.