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

Trending Topics

Online now

Members online
1,100
Guests online
2,840
Total visitors
3,940

Forum statistics

Threads
2,328,681
Posts
29,243,797
Members
1,157,980
Latest member
mikhs06
Back
Top