Question #49975

To write a program which inputs 30 integers in a 1-d array and using user defined function find index number at which the maximum integer is found. the function should return the index which should be shown in a suitable variable in main and displays the value in main itself.

Expert's answer

// The libraries

//To write a program which inputs 25 integers in a 1-d array

//and copies all even integers in another array and all odd integers in third array.

//

#include <iostream>

#include <cstdio>

#include <cmath>

#include <string>

#include <fstream>

using namespace std;

int main()

{

const int N=30;

int arr[N];

cout<<"Enter 30 number please"<<endl;

int temp_number=0;

int temp_number_index=0;

for (int i=0;i<N;i++)

{

cout<<"["<<i+1<<"]"<<":";

cin>>arr[i];

if (arr[i] > temp_number ) temp_number=arr[i];temp_number_index=i;

}

cout<<"Maximum number in array"<<temp_number<<" index in array is: "<<temp_number_index<<endl;

return 0;

}

//To write a program which inputs 25 integers in a 1-d array

//and copies all even integers in another array and all odd integers in third array.

//

#include <iostream>

#include <cstdio>

#include <cmath>

#include <string>

#include <fstream>

using namespace std;

int main()

{

const int N=30;

int arr[N];

cout<<"Enter 30 number please"<<endl;

int temp_number=0;

int temp_number_index=0;

for (int i=0;i<N;i++)

{

cout<<"["<<i+1<<"]"<<":";

cin>>arr[i];

if (arr[i] > temp_number ) temp_number=arr[i];temp_number_index=i;

}

cout<<"Maximum number in array"<<temp_number<<" index in array is: "<<temp_number_index<<endl;

return 0;

}

Learn more about our help with Assignments: C++

## Comments

## Leave a comment