🔒 Closed C++ Print element of an array [SOLVED]

Status
Not open for further replies.

Phrog

Forum Veteran
Tanong ko lang po paano po ipirprint ang laman ng array, alam ko po yung printing lang, pero ang balak ko po sana
iprint sya kasama yung na iinput
example po Math: 90, English: 90 and so on.
C++:
//array
string mySubjects[]= {"Mathematics", "English", "Filipino", "Science", "MAPEH"};
//loop for asking the user
for(int i = 0; i < 5; i++){
    for(int j = 0; j < i; ++j){
        cout << mySubjects[i];
         cin >> grades[j];
    }
}

Eto po yung code, nested for loop, nag kaka problem po ako, nag sstart po sya sa second element
Saka po nag dodouble yung Element, pag ka print po ng English, meron na naman, saka s aibang subject din

Thank you po in advance
 
C++:
    string mySubjects[5]= {"Mathematics", "English", "Filipino", "Science", "MAPEH"};
    int scores[5]={};
    for(int i=0; i<5; i++){
        cout<<mySubjects[i]<<": ";
        cin>>scores[i];
    }
    for(int i=0; i<5; i++){
        cout<<mySubjects[i]<<": ";
        cout<<scores[i]<<"\t";
    }
 
C++:
    string mySubjects[5]= {"Mathematics", "English", "Filipino", "Science", "MAPEH"};
    int scores[5]={};
    for(int i=0; i<5; i++){
        cout<<mySubjects[i]<<": ";
        cin>>scores[i];
    }
    for(int i=0; i<5; i++){
        cout<<mySubjects[i]<<": ";
        cout<<scores[i]<<"\t";
    }
Thank you po, try ko po sya ngayon!
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 722
    Views
  • 4
    Participants
Last reply from:
Tagaromike

Trending Topics

Online now

Members online
1,226
Guests online
3,399
Total visitors
4,625

Forum statistics

Threads
2,308,310
Posts
29,184,412
Members
1,191,934
Latest member
Colmi
Back
Top