Shape A | Sololearn: Learn to code for FREE!

+1

Shape A

How can I use arrays instead of the sentence on Line 7? https://code.sololearn.com/coxG3PhfjT8Q/?ref=app

c++

9/29/2020 3:56:12 PM

Alaa Z. Abu Zuhair

4 Answers

New Answer

+2

Alaa Z. Abu Zuhair nice try👍 but here are couple things you overlooked in your code :- 1) array index starts from 0 not 1 2) your else statement is inside the second *for* loop and will execute every time the if statement is false. { Just bring it outside} After applying all the fixes your code should look something like this👇 https://code.sololearn.com/cmGg1DpWYoTU/?ref=app

+4

Fill all those values in an array and then for every iteration just check if that value is in the array of not.

+1

Thanks Arsenic , I tried it but it didn't look right.. I wanted the letter A to appear on the output screen int main(){ int i,j; int A[7]={5,9,11,20,26,27,35}; for (i=1;i<=35;++i){ if(i>=14&&i<=18) goto one; for (j=1;j<=7;++j){ if(A[j]==i)goto one; else { cout<<" "; continue ; } } one: cout<<"*"; if (i==9||i==20||i==27)continue; if (i>=14&&i<=17)continue ; else cout<<"\n"; } return 0; }

+1

Ok👍 Thanks , I am grateful to you Arsenic