473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

already done the code but the output come out wrong , some one help me

2
#include<iostream>
using namespace std;
int setFirst(int alpha[],int beta[]);
int inputArray(int alpha[]);
double doubleArray(int alpha[],int beta[]);
void copyAlphaBeta(int matrix[][4], const int numberOfRows, const int
alpha[], const int beta[], int numSize);
int printArray(int print[],int n);

int main()
{
int alpha[20];
int beta[20];
int matrix[10][4];

inputArray(alpha);
cout<<"Alpha after reading 20 numbers"<<endl;
printArray(alpha, 20);
cout<<endl;

doubleArray(alpha, beta);
cout << "Beta after a call to doubleArray" << endl;
printArray(beta, 20);
cout<<endl;

copyAlphaBeta(matrix, 10, alpha, beta, 20);
for (int row=0; row<10;row++)
for (int col=0; col<4; col++)
{
if (col%4==0)
cout << endl;
cout<<matrix[row][col]<<'\t';
}
cout<<endl;

return 0;
}

int setFirst(int alpha[],int beta[])
{
for(int i=0;i<20;i++)
{
alpha[i]=0;
beta[i]=0;
}
cout<<endl;
}
int inputArray(int alpha[])
{
cout<<"Enter 20 integers:"<<endl;
for(int i=0;i<20;i++)
{

cin>>alpha[i];
}
cout<<endl;
return 0;
}
double doubleArray(int alpha[],int beta[])
{
for(int i=0;i<20;i++)
{
beta[i]=2*alpha[i];
}
cout<<endl;
return 0;
}
void copyAlphaBeta(int matrix[][4], const int numberOfRows, const int
alpha[], const int beta[], int numSize)
{
cout << endl;
cout << "Matrix after a call to copyAlphaBeta" << endl;

for(int r=0;r<numberOfRows;r++)
{
for(int c=0;c<4;c++)
{
for (int counter=0; counter<numSize; counter++)
{
if(r<5)
{
matrix[r][c]=alpha[counter];
}
else if (r>=5)
{
matrix[r][c]=beta[counter];
}
}
}
}

cout << endl;
}
int printArray(int print[],int n)
{
cout << endl;
for (int i=0;i<n;i++)
cout << print[i] << " ";
cout << endl;
}[/code]
Attached Files
File Type: pdf LAB TEST 2.pdf (430.3 KB, 130 views)
Dec 5 '18 #1
2 1401
ally99
2
Look the output at attached file, thanks.
My due is tonight, help me asap,ty
Dec 5 '18 #2
weaknessforcats
9,208 Expert Mod 8TB
Have you stepped through this code using your debugger?

If not, this is an excellent time to learn how to use it, Debugging code is just as important as being able to write it.

Just run the code using the debugger and step through it. You will see the values of all of your variables as you go.
Dec 6 '18 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jeffcbr | last post by:
I am very new to programming and do not know what is wrong with this code... project due soon. need feedback asap please... #include <stdio.h> // Constant #define COST_OF_GLASS .02
4
by: setiarakesh | last post by:
I have designed a socket Server and developed asynchronous server . It is working fine with 60 Clients which are connecting to ths Server running at Machine (2 GB RAM and OS is Windows 2003...
2
by: creative1 | last post by:
I get following error on page : Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\desiorb\411.php:9) in C:\xampp\htdocs\desiorb\411.php on line 21 when...
9
by: pejy69 | last post by:
Hi My name is PJ and i'm an adult student who requires a pointer in the right direction. Below is a snippett of the code that i believe i have something wrong in but cant work out what i have done...
3
by: dannynez | last post by:
my problem is in line 58 - header("Location: ".$MM_redirectLoginSuccess); and in line 61-header("Location: ".$MM_redirectLoginFailed); i get this (Warning: Cannot modify header information -...
20
nicebasic
by: nicebasic | last post by:
I would like to have a query for ASP Classic to be applied on an Access database. 1. Imagine that we have a table with the name of "Country". 2. Imagine that we have a column in "Country" that...
1
by: gdguy26 | last post by:
What is wrong with this code? This code has been given to me by one of my friends and told me to help him troubleshoot. I am using xampp 1.7.3 installed in the I: drive and my OS is win xp. I...
10
by: Andrew V | last post by:
This is my code and i dont know why when i enter let's say x=3 and n=0 it gives 3. #include <cstdlib> #include <iostream> using namespace std; int main() ...
8
by: freedemi | last post by:
Hi, I ll try to find a way to find the missing number from range of numbers from a specific field and show this number with msgbox. Any ideas? Thanks in advance.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.