Can anyone tell what the error because I cannot get the output.

Write a program that read from the screen a list of 5 integers values as one dimensional array by using a loop. The main program should called the function int Darab2(int value) to multiply two of each of the 5 integers values in the input list.
#include <iostream>
#include <conio.h>

using namespace std;

void main()
{
int i, value;
int a[5];
int Darab2(int value);

cout << "Enter a list of five integers: ";
for(i = 0; i < 5; i++)
cin >> a[i];

Darab2(value);

cout << "The resulted list is " << Darab2(value) << endl;

_getch();
}
int Darab2(int value)
{
int i, a[5];
int b = 2;
for(i = 0; i < 5; i++)
cin >> a[i];
value = b * a[i];
return value;
}
Your code has so many errors to point out individually.
If i understand it correct your code should be looking similar to this;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;

void Darab2(int x[]);

int main()
{
	int a[5];
	

	cout << "Enter a list of five integers:\n";
	for (int i=0; i<5; i++) cin >> a[i];
	
	Darab2(a);

	cout << "\nThe resulted list is:\n";
	for (int i=0; i<5; i++) cout << a[i] << endl;

	_getch();
	return 0;
}

void Darab2(int x[5])
{	
	for (int i=0; i<5; i++) x[i] *= 2;
}


Feel free to ask anything you don't understand.
-quine.
Topic archived. No new replies allowed.