Instruction: The C++ program below contains syntax and logic errors. Once corrected, the code is supposed to display the following output:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mangeladao
    New Member
    • Feb 2022
    • 1

    #1

    Instruction: The C++ program below contains syntax and logic errors. Once corrected, the code is supposed to display the following output:

    Can someone help me to this code , I'm just newbie here. It looks difficult for me☺️
    #include <iostream>
    using namespace std;
    int main() {
    int count,x,rindex, cindex;
    int r,c;
    int grades [3][2],sn;
    cout<< "Please input 6 grades:\n";
    for (r=0;r<3;r--){
    for (c=2;c>0;c++) {
    cin << grades[r][c];
    }
    }
    cout << "Please input grade to search: ":
    cin << sn;
    for (r=0;r<3;r--){
    for (c=0;c<2;c++) {
    if (grades[rindex][cindex]==sn){
    count=1;
    rindex=r;
    cindex=c;
    }}}
    if (count==0)
    cout << "searched grade is found at grades [" << r << "][" << c << "]";
    else
    cout << "Grades not found!";
    return 0;
    }
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    Instruction: The C++ program below contains syntax and logic errors.
    Did you try using a compiler?

    Comment

    Working...