Sponsored Links


Results 1 to 2 of 2

Thread: I would able to program in c++ I would be able to program in every language.

  1. #1
    sana.pari
    Guest

    Icon14 I would able to program in c++ I would be able to program in every language.

    Sponsored Links1


    RESPECTED SIR,your way of teaching is very simple and unique I learnt many things from yours way of teaching

    sir i have coded this problem but the result is not good. I want to tranpose the matrix but the

    matrix is not transposed please tell me the mistakes and give me the correct code

    I would be grateful to you. Sir can you tell me that which language is good for learning

    Sponsored Links

    and if I would able to program in c++ I would be able to program in every language.

    #include<iostream.h>
    #include<conio.h>
    const int maxrows=3;
    const int maxcols=3;
    void readmatrix(int a[][maxcols]);
    void displaymatrix(int a[][maxcols]);
    void transposematrix(int a[][maxcols]);
    main()
    {
    int a[maxrows][maxcols];
    readmatrix(a);
    cout<<endl;
    cout<<"DISPLAY MATRIX ";
    cout<<endl;
    displaymatrix(a);
    cout<<endl;
    cout<<"TRANPOSE THE MATRIX ";
    cout<<endl;
    displaymatrix(a);
    cout<<getch();
    }
    void readmatrix(int a[maxrows][maxcols])
    {
    int rows;
    int cols;
    for (rows=0;rows<maxrows;rows++)
    {
    for (cols=0;cols<maxcols;cols++)
    {
    cout<<"PLEASE ENTER THE NUMBER";
    cout<<rows;

    cout<<cols;
    cin>>a[rows][cols];
    }
    cout<<'\t';
    cout<<endl;
    }
    }

    void displaymatrix(int a[][maxcols])
    {
    int rows;
    int cols;
    for (rows=0;rows<maxcols;rows++)
    {
    for (cols=0;cols<maxcols;cols++)
    {



    cout<<a[rows][cols];
    cout<<'\t';
    }
    cout<<endl;
    }
    }
    void transposematrix(int a[maxrows][maxcols])
    {
    int rows;
    int cols;
    int temp;
    for (rows=0;rows<maxrows;rows++)
    {
    for (cols=rows;cols<maxcols;cols++)
    {
    temp=a[rows][cols];
    a[rows][cols]=a[cols][rows];
    a[cols][rows]=temp;
    }
    }
    }

  2. #2
    Dear Student,

    Below is the corrected modified code of your program.

    #include<iostream.h>
    #include<conio.h>

    const int maxrows=3;
    const int maxcols=3;

    void readmatrix(int a[][maxcols]);
    void displaymatrix(int a[][maxcols]);
    void transposematrix(int a[][maxcols]);

    main()
    {
    int a[maxrows][maxcols];

    readmatrix(a);

    cout<<endl;
    cout<<"DISPLAY MATRIX:\n\n";


    displaymatrix(a);

    cout<<"\nTRANPOSE THE MATRIX ";
    cout<<endl;

    transposematrix(a);

    displaymatrix(a);

    cout<<getch();
    }


    void readmatrix(int a[maxrows][maxcols])
    {
    int rows;
    int cols;

    for (rows=0;rows<maxrows;rows++)
    {
    for (cols=0;cols<maxcols;cols++)
    {

    cout<<"PLEASE ENTER THE NUMBER FOR ROW "<<rows << " AND COLUMN " <<cols;
    cout<<":\t";
    cin>>a[rows][cols];

    }
    }

    }

    void displaymatrix(int a[][maxcols])
    {
    int rows;
    int cols;

    for (rows=0;rows<maxcols;rows++)
    {
    for (cols=0;cols<maxcols;cols++)
    {
    cout<<a[rows][cols];
    cout<<"\t";
    }

    cout<<endl;
    }
    }


    void transposematrix(int a[maxrows][maxcols])
    {
    int rows;
    int cols;
    int temp;


    for (rows=0;rows<maxrows;rows++)
    {
    for (cols=rows;cols<maxcols;cols++)
    {
    temp=a[rows][cols];
    a[rows][cols]=a[cols][rows];
    a[cols][rows]=temp;
    }
    }

    // displaymatrix(a);
    }


    The problem with you program was that you were not calling transpose function in your main function and also there were some issue with your cout statements.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. c++ program on unix
    By varup in forum C++ Programing
    Replies: 0
    Last Post: 10-10-2012, 06:16 PM
  2. what is program in C++ May 2011 ?
    By Vuhelper in forum C++ Programing
    Replies: 0
    Last Post: 05-30-2011, 03:00 PM
  3. What data type will be used in C++ program?
    By sana.pari in forum C++ Programing
    Replies: 1
    Last Post: 04-24-2011, 06:07 PM
  4. Why we use iostream.h in our program?
    By Xpert in forum C++ Programing
    Replies: 0
    Last Post: 04-24-2011, 02:04 AM
  5. Fee structure toward mcs program for vu graduates
    By Xpert in forum Universities Announcement
    Replies: 0
    Last Post: 10-11-2010, 07:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft