hello everyone i have an assimeant and i face some proplem with it

the assimeant consider 5 parts

for part A ..

Write a function named 7that output the elements of an integer array.

and i write this

void outputarr(int a[], size){

for ( int i = 0 , i < size , i ++ )

cout<<a[i];}

and part b ..

Write a function named readarr that reads the elements of an integer array

void reader(int a[])

{

int i = 0;

ifstream input;

input.open(a);

while (i != input.eof())

{

input >> a[i];

i++;

}

input.close();

but i am not sure from codes

and i cant start solveing the other , i feel that i am confused

so can any one help me as soon as possible

this is the rest of the qustions

PART C consider

Write a function named maxPosition that takes an array of integers intList, and the

The index of the last element in the array(last). The function should return the Position (Location) of the

maximum value in the array (a number between 0 and last).

For example, if the following array intList :

25 99 35 40 45 50 55 888 65 70

is called with the value of last as 9 it should return 7,

but if it is called with the value of last as 6 it should return 1.

PARTD

Use the above function of part C to write a selectionsort function to sort an array of integers in

descending order (High to low).

PART F

Write a main function to test the above functions.

1. Declare an integer array named Arr with maximum size 50.

2. Read 10 integers into array Arr (call function readtarr)

3. Output the array before sorting( call function outputarr).

4. Sort the array using function selectionsort

5. Output the array after sorting( call function outputarr).

the assimeant consider 5 parts

for part A ..

Write a function named 7that output the elements of an integer array.

and i write this

void outputarr(int a[], size){

for ( int i = 0 , i < size , i ++ )

cout<<a[i];}

and part b ..

Write a function named readarr that reads the elements of an integer array

void reader(int a[])

{

int i = 0;

ifstream input;

input.open(a);

while (i != input.eof())

{

input >> a[i];

i++;

}

input.close();

but i am not sure from codes

and i cant start solveing the other , i feel that i am confused

so can any one help me as soon as possible

this is the rest of the qustions

PART C consider

Write a function named maxPosition that takes an array of integers intList, and the

The index of the last element in the array(last). The function should return the Position (Location) of the

maximum value in the array (a number between 0 and last).

For example, if the following array intList :

25 99 35 40 45 50 55 888 65 70

is called with the value of last as 9 it should return 7,

but if it is called with the value of last as 6 it should return 1.

PARTD

Use the above function of part C to write a selectionsort function to sort an array of integers in

descending order (High to low).

PART F

Write a main function to test the above functions.

1. Declare an integer array named Arr with maximum size 50.

2. Read 10 integers into array Arr (call function readtarr)

3. Output the array before sorting( call function outputarr).

4. Sort the array using function selectionsort

5. Output the array after sorting( call function outputarr).

Part B:

1.`char*` as argument - not an array of int.

2. What are you doing in`reader()`? You're comparing an index against the inputs end-of-file condition?

3. You should ensure to not overwrite your array boundaries. So give your function another parameter offering the arrays size in bytes. A better way would be to use f.e. std::vector. It manages its size internally.

1.

`input.open(a);`

will result in a compilation error because open expects a 2. What are you doing in

3. You should ensure to not overwrite your array boundaries. So give your function another parameter offering the arrays size in bytes. A better way would be to use f.e. std::vector. It manages its size internally.

#include <iostream>

using namespace std;

void outputarr(int list [] , int size)

{

for ( int i = 0 , i < size , i++ )

cout<<list [i]<<" " ;

cout<<endl;

}

void readarr ( int list [] , int size );

{

for ( int i = 0 , i < size , i ++ )

cin>>list[] ;

}

int maxposition (int list[] , int s , int l )

{

int max = list[s], pos=s ;

for (int i = 0, i <l , i ++)

if (list [i] > max )

{ max = list [i] ;

pos=i ; }

int temp,big,pos;

for(int i = 0 ; i<s-1;i++)

{

big = list[i];

pos = i ;

for ( int j = 0 ; j <s ; j ++ )

if ( list[j] > big )

{

big = list [j];

pos= j ; }

}

temp = list[i];

list[i] = big ;

list[pos] = temp ;

return pos;

}

int main ()

{

int m[], size, finall;

cout<<"enter the numbers please " <<endl;

cin>>size;

cout<<endl;

readarr(m,size);

outputarr(m,size);

cout<<"enter the last number please"<<endl;

cin>>finall;

cout<<"the biggest number is: ";

maxposition(m,finall,size);

cout<<endl;

cout<<"the array is : " <<endl;

outputarr(m,size);

cout<<endl;

return 0 ;

}

this is my new codes but i still have errors !?

using namespace std;

void outputarr(int list [] , int size)

{

for ( int i = 0 , i < size , i++ )

cout<<list [i]<<" " ;

cout<<endl;

}

void readarr ( int list [] , int size );

{

for ( int i = 0 , i < size , i ++ )

cin>>list[] ;

}

int maxposition (int list[] , int s , int l )

{

int max = list[s], pos=s ;

for (int i = 0, i <l , i ++)

if (list [i] > max )

{ max = list [i] ;

pos=i ; }

int temp,big,pos;

for(int i = 0 ; i<s-1;i++)

{

big = list[i];

pos = i ;

for ( int j = 0 ; j <s ; j ++ )

if ( list[j] > big )

{

big = list [j];

pos= j ; }

}

temp = list[i];

list[i] = big ;

list[pos] = temp ;

return pos;

}

int main ()

{

int m[], size, finall;

cout<<"enter the numbers please " <<endl;

cin>>size;

cout<<endl;

readarr(m,size);

outputarr(m,size);

cout<<"enter the last number please"<<endl;

cin>>finall;

cout<<"the biggest number is: ";

maxposition(m,finall,size);

cout<<endl;

cout<<"the array is : " <<endl;

outputarr(m,size);

cout<<endl;

return 0 ;

}

this is my new codes but i still have errors !?

Please PLEASE **PLEASE**: Use the **Source Code** tag: Those little button at the right of the editor field marked '<>'.

Please think about others reading and trying to understand your - and not only yours - code.

Please think about others reading and trying to understand your - and not only yours - code.

this is my new codes but i still have errors !? |

And another

An advise not only intended to moosa94:

For more details on using this forum see

Topic archived. No new replies allowed.