hi every one i need now to know the wrong on this program pLZ
write a program that defines the following function:
.int ReadDate (int[]x)
read from the user an integer N follwed by N integers.the N integer will be saved in the parameter array x.the function returns the number of data items being read ,i.e .N
void printData (int[]x,int N)
prints the first N integers in array x .the items should be printed on the same line ,separated by ',' and with a fullstop '.' at the end ,followed by a new line.
bool allpositive (int []x,int N)
this function return true if all N integers in x are positive.
bool allsorted(int [] x, int N)
this function return true if all n integer in x are sorted in an ascending (nondecreasing) order.
void computeSum(int[], int [], int N)
this function will set elements in array y such that the value of y[k] (k=0..N)is equal to the sum of all items from x[0] to x[k] (inclusive.)
the main program will call ReadData to get the data from the user,and then it will print the following information:
1.print the data using printData.
2.print if the data is sorted or not.
3.print if the data is all positive or not.
4.call computeSum and prints the resulting array.
you assume tht the user will not enter more than 100 integers.
study the following sample input /output . the text in bool is typed by the user while the regular text is printed by the program.
I need data : 5 -4 12 16 36 42
Data is: -4 , 12, 16 36, 42.
The data IS sorted.
The Data IS NOT all positive .
Data Sum is: -4,8 ,24 ,60 ,102.
Thank you.
bool allstored ( int x[] , int N ) {
for(int i=0 ;i<N ;i++){
int m=i;
for ( int j=0 ; j<N ; j++){
if ( x[j]>x[m]){
m=j;
return false;
}
return true ;
}
}
void ComputeSum(int x[],int y[] ,int N){
int count=0;
cout << " Data Sum is :";
for(i=0;i<N;i++)
{
y[count]=y[count]+x[i];
cout << y[count] ;
if(i<n-1)
{
cout << ", ";
}
}
cout <<" .";
}
int main (){
int N;
int x[100];
cout << " I need data :";
int n = readdata(x);
cout << " Data is :";
printData (x,n);
if ( allstored){
cout << " The Data is stored ";
}
else
}
else
{
cout << "The data IS not sorted ";
if (allPositive){
cout <<" Data is Not all positive . ";
}
else
{
cout << "The Data all positive ";
}
ComputeSum ( x, y , n ){
cout << " THANK YOU ";