fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7. int ar[2][3];//declaration for 1 row and 2 columns
  8. int i,j;
  9. int sum_col2 = 0;
  10.  
  11.  
  12. for(i=0; i<=1;i++)//loop for 2 rows
  13. {
  14. for(j=0;j<=2;j++)//loop for 3 columns
  15. ar[i][j] = i*10;
  16.  
  17. }
  18. }
  19.  
  20.  
  21. for(i=0; i<=1;i++)
  22. {
  23. for(j=0;j<=2;j++)//printing each element of row no. i
  24. cout <<" " <<ar[i][j];
  25.  
  26. cout <<endl;//moving to the next line after the current row has been printed cimpletely
  27.  
  28. }
  29.  
  30. for(j=0;j<=2;j++)
  31. {
  32. sum_col2 = sum_col2 + ar[i][2]
  33. cout<< "sum of col 2 = " <<sum_col2<<endl;
  34. }
  35. return 0;
  36.  
  37. }
  38.  
  39.  
  40.  
  41.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:21:5: error: expected unqualified-id before ‘for’
     for(i=0; i<=1;i++)
     ^~~
prog.cpp:21:14: error: ‘i’ does not name a type
     for(i=0; i<=1;i++)
              ^
prog.cpp:21:19: error: ‘i’ does not name a type
     for(i=0; i<=1;i++)
                   ^
prog.cpp:30:5: error: expected unqualified-id before ‘for’
     for(j=0;j<=2;j++)
     ^~~
prog.cpp:30:13: error: ‘j’ does not name a type
     for(j=0;j<=2;j++)
             ^
prog.cpp:30:18: error: ‘j’ does not name a type
     for(j=0;j<=2;j++)
                  ^
prog.cpp:35:9: error: expected unqualified-id before ‘return’
         return 0;
         ^~~~~~
prog.cpp:37:1: error: expected declaration before ‘}’ token
 }
 ^
stdout
Standard output is empty