Can anyone correct the following code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone correct the following code?

I need to automatically take a name from std array and put it one cout below the first loop; ANYONE HELP #include <iostream> using namespace std; main() { //Two dimentional Array with nested for loops string stds[2][3] = { {"Ahmad"}, {"Mahmood"} }; int marks[2][3]; int a, j, k, l; for (a=1; a<=2; a++){ cout<<stds[a]<<endl; for(j=1; j<=3; j++){ cout<<"Enter Marks "; cin>>marks[a][j]; } } cout<<endl; }

8th Apr 2017, 6:14 AM
Esmatullah Sayeedy
Esmatullah Sayeedy - avatar
1 Answer
+ 5
1) There is no need to use 2 dimensional array for just 2 strings. 2) main() should be int main() 3) Array index starts from 0 not from 1.
8th Apr 2017, 2:07 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar