Shape A | Sololearn: Learn to code for FREE!


Shape A

How can I use arrays instead of the sentence on Line 7?


9/29/2020 3:56:12 PM

Alaa Z. Abu Zuhair

4 Answers

New Answer


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👇


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


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; }


Ok👍 Thanks , I am grateful to you Arsenic