In this lab, you add two for loops to print an asterisk or a space in columns an
ID: 3862637 • Letter: I
Question
In this lab, you add two for loops to print an asterisk or a space in columns and rows to print out the letter A. the outer loop goes through each row. the inner loop moves from column to column. the inner loop will contain if then else statements that will decide whether to print an asterisk or a space. When a column is complete you have to print an end line statement. the output will look like: Open the source code file named LetterASt.cpp in Dev C++ Write the for loops to control the number of rows and columns that make up the letter A. the outer loop should go through the rows and the inner loop through the columns. In the inner loop write the if then else statements to decide when to print an asterisk or a space. Decide where you will need an end line statement to be printed after you have finished printing out a row and add it to the code in the proper place. Compile and run your program. Submit your completed source file.Explanation / Answer
Greetings.
In the question, you have been asked to modify the source code from a given location. However, since we cannot access the source code, I have written a small code snippet satisfying the conditions given in the question. PFB :
************************************************************************
int main() {
int i,j;
for(i=0;i<5;i++){ //ans to que 2
for(j=0;j<5;j++){ //ans to que 2
if(i==0 or i==2){ //ans to que 3 follows
cout<<"*";
}
else{
if(j==0 or j==4){
cout<<"*";
}
else{
cout<<" ";
}
}
}
cout<<endl; //answer to que 4
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.