So I\'ve created a function in c++, but I\'m trying to use a cin input in main i
ID: 3650274 • Letter: S
Question
So I've created a function in c++, but I'm trying to use a cin input in main in that function. How do I run that cin function from main into another function. For example,#include<iostream>
using namespace std;
int getvalue(int a[][col]);
int main()
{
int x;
cin >> row;
cin >> column;
cout << getvalue << endl;
return 0;
int getvalue(int a[][col])
{
int i,j,sum=0;
for(i=0;i<row;i++)
{
for(j=0;j<column;j++)
{
sum+=a[i][j];
}
}
return sum;
}
I've been getting errors while trying to do something like this. I'm just trying to run the cin variable in the function that will spit something back out. I hope it's possible. Please help.
Explanation / Answer
Take reference from the following code, here I am taking numbers as input values: #include using namespace std; const int SIZE = 10; / you have made the size as 10 what if the user wants a 20*10 matrix? int getTotal(int x,int w) { int total = 0; int input, number[SIZE][SIZE]; for(int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.