C++/using a nested loop in dev c++
Expert: Tehreem - 2/5/2012
QuestionYour task is to display on screen the 'N' symbol given two data: the length and the character symbol to use to draw the symbol. If the input of the user is less than 3, print "Erros: Length must be greater than 2" and ask again the user to input a valid length.
This program repeats unless the user types -1.
Sample Run:
Enter length and character: 5 0
00000
00000
00000
00000
00000
AnswerSorry i could not respond to you earlier. Here is the code you need:
#include<iostream>
using namespace::std;
int main(void)
{
int in;
char symbol;
cin>>in;
do
{
cin>>symbol;
while(in<3)
{
cout<<"Error: Length must be greater than 2"<<endl;
cin>>in>>symbol;
}
for(int j=0; j<in; j++)
{
for(int i=0; i<in; i++)
cout<<symbol;
cout<<endl;
}
cin>>in;
}while(in!=-1);
return 0;
}