🔒 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
  • 700
    Views
  • 4
    Participants
Last reply from:
Tagaromike

Trending Topics

Online now

Members online
1,033
Guests online
1,227
Total visitors
2,260

Forum statistics

Threads
2,274,059
Posts
28,953,407
Members
1,235,039
Latest member
Drifter007
Back
Top