Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6994801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:56:18+00:00 2026-05-27T19:56:18+00:00

Here is the original code of Visual C++ which I have been trying to

  • 0

Here is the original code of Visual C++ which I have been trying to manipulate for more than a day.
This is the simplest error-free program which runs correctly.
What I want to do is insert two functions: one for taking input from a user, and another for displaying output.

#include<iostream>
#include<iomanip>
using namespace std;

void main()
{
    int i, j,r,c;
    int arr[5][5];
    cout<< "enter r and c";
    cin>> i>> j;

    for(r=1;r<=i;r++)
    {
        for(c=1;c<=j;c++)
        {
            cout<< "enter elements";
            cin>> arr[r][c];
        }
    }

    cout<< " elements are"<< endl;
    for(r=1;r<=i;r++)
    {
        for(c=1;c<=j;c++)
        {

            cout<<setw(4) <<arr[r][c];
        }
        cout<< endl<< endl;
    }

    cin.ignore();
    getchar();
}

This is what I tried doing but it’s giving errors.

#include<iostream>
#include<iomanip>
using namespace std;
int input(int i, int j, int arr)
{   
    int r,c;
    for(r=1;r<=i;r++)
    {
        for(c=1;c<=j;c++)
        {
            cout<< "enter elements";
            cin>> arr[r][c];

        }
    }
    return arr[r][c];
}
void output(int i, int j, int arr)
{   
    int r,c;
    for(r=1;r<=i;r++)
    {
        for(c=1;c<=j;c++)
        {

            cout<<setw(4) <<arr[r][c];
        }
        cout<< endl<< endl;
    }
}

void main()
{
    int i, j,r,c;
    int arr[5][5];
    cout<< "enter r and c";
    cin>> i>> j;

    input(i,j,arr);

    cout<< " elements are"<< endl;

    output(i,j,arr);
    cin.ignore();
    getchar();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:56:19+00:00Added an answer on May 27, 2026 at 7:56 pm

    You really need a deeper understanding of C++, pointers, and functions. The following is what you are looking for (of sort), however, you certainly need a much deeper understanding of C++:

    #include<iostream>
    
    using namespace std;
    
    void output(int ** array)
    {
        for (int i= 0;i<5;++i)
        {
            for (int a= 0;a<5;++a)
            {
                cout << "Array[" << i << "][" << a << "] = " << array[a][i] << endl;
            }
        }
    }
    
    void input(int ** array)
    {
        for (int i= 0;i<5;++i)
        {
            for (int a= 0;a<5;++a)
            {
                cout << "Array[" << i << "][" << a << "] = " << endl;
                cin >> array[i][a];
            }
        }
    }
    
    int main()
    {
        int** array;
        array = new int*[5];
        for (int i=0;i<5;++i)
            array[i] = new int[5];
        input(array);
        output (array);
        delete []array;
        cin.ignore();
        getchar();
        return 0;
    }
    

    The problem is, explaining this would be like teaching you C++ from scratch. Whatever method you are using to learn C++, stick with it. You will get there, you’re just not quite ready. One thing you will find is it’s not always easy to take things to the next level. There is a reason things go and stop where they do when learning. Though, taking that extra step, or attempting to, isn’t bad, you just need to know when it isn’t time, yet.

    Edit:

    For the sake of completion, here is an example with no pointers:

    #include<iostream>
    
    using namespace std;
    
    void output(int array[5][5])
    {
        for (int i= 0;i<5;++i)
        {
            for (int a= 0;a<5;++a)
            {
                cout << "Array[" << i << "][" << a << "] = " << array[a][i] << endl;
            }
        }
    }
    
    void input(int array[5][5])
    {
        for (int i= 0;i<5;++i)
        {
            for (int a= 0;a<5;++a)
            {
                array[i][a] = i*a;
            }
        }
    }
    
    int main()
    {
        int array[5][5];
        input(array);
        output (array);
        cin.ignore();
        getchar();
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parallelize a convolution function in C. Here's the original function which
Here is my original code: <tr class=song id='.$this->i.'> <td class=clickable id=td1_'.$this->i.'> ... </td> </tr>
Code styling question here. I looked at this question which asks if the .NET
here is the original code: public static int getInt () { Scanner in =
Let's say I have some original text: here is some text that has a
This question is sort of a follow-up to my original question here . Let's
My original question can be found here , for which I've gotten some great
Here is the original code: if (($handle = fopen($source_file, r)) !== FALSE) { $columns
###########Update Here is the original code that worked in ie7 but not in 9.
Here is the original code: public class FruitGrower { public void growAFruit(String type) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.