i++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • keith katthy
    New Member
    • Oct 2007
    • 24

    #1

    i++

    Dear all,

    I have done this programming, but i want the ouput of i is increasing i++, but i dont know how to do. Can somebody help me?

    [code=cpp]
    # include<iostrea m.h>
    #include<conio. h>

    void main()
    {
    int a[6][6] ;
    int i, j;

    int clrscr();


    { for(i=0;i<6;i++ )
    for(j=0;j<6;j++ )
    {

    cout<<"[i][j]";

    cin>>a[i] [j] ;

    }

    }
    for(i=0;i<4;i++ )
    {
    cout<<endl;
    for(j=0;j<4;j++ )
    cout<<a[j][i]<<"\t";
    }
    getch();
    }
    [/code]
    Last edited by JosAH; Oct 7 '07, 09:51 AM. Reason: added [code] ... [/code] tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Please indent your code properly; the way you've done it now makes me dizzy.
    btw it's "int main()" not "void main()" and please rephrase your question.

    kind regards,

    Jos

    Comment

    • keith katthy
      New Member
      • Oct 2007
      • 24

      #3
      Dear Josah

      I have change to int main. So, my problem is to i and j in increasing , i ++?How to get that

      [code=cpp]
      # include<iostrea m.h>
      #include<conio. h>

      int main()
      {
      int a[6][6] ;
      int i, j;

      int clrscr();


      { for(i=0;i<6;i++ )
      for(j=0;j<6;j++ )
      {
      cout<<"[i][j]";

      cin>>a[i] [j] ;

      }

      }
      for(i=0;i<4;i++ )
      {
      cout<<endl;
      for(j=0;j<4;j++ )
      cout<<a[j][i]<<"\t";
      }
      getch();
      }
      [/code]
      Last edited by JosAH; Oct 7 '07, 10:25 AM. Reason: added those [code] ... [/code] tags again.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by keith katthy
        Dear Josah

        I have change to int main. So, my problem is to i and j in increasing , i ++?How to get that
        Your indentation style still makes me dizzy; I apologize but I don't understand
        what you mean by 'to i and j in increasing, i++'. You are incrementing i and j in
        you code don't you?

        kind regards,

        Jos

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          First: main() returns an int not a void.

          Second: Why are you using iostream.h?? That was the pre-ANS header used before 1998. You should be using iostream. If your compiler doesn't support that then it is 10 years out of date and you need a new compiler.

          Third: getch() is a deprecated POSIX function. Use the ISO C++ conformant _getch instead.

          Fourth: It hurts to read your code. I restyled it using the elliptical style where the braces at the same level are aligned verically. The result is below and looks odd between lines 14 and 25. What were you indentding there??
          [code=c]
          #include <iostream>
          using namespace std;
          //# include<iostrea m.h>
          #include<conio. h>

          int main()
          {
          int a[6][6] ;
          int i, j;

          int clrscr();


          {
          for(i=0;i<6;i++ )
          for(j=0;j<6;j++ )
          {

          cout<<"[i][j]";

          cin>>a[i] [j] ;

          }

          }
          for(i=0;i<4;i++ )
          {
          cout<<endl;
          for(j=0;j<4;j++ )
          cout<<a[j][i]<<"\t";
          }
          _getch();
          }
          [/code]

          Comment

          Working...