//program on passing array and its size as parameters
//displays the index value of minimum element
#include<iostream>
using namespace std;
int k;
int minindex(int a[],int n)
{
int mini=a[0];
for(int i=0;i<n;i++)
{
if(mini>a[i])
{
mini=a[i];
k=i;//Storing index value
}
}
return k;// Returning index value
}
int main()
{
int a[20],n,min;
cout<<"How many numbers you want to enter"<<endl;
cin>>n;
cout<<"Enter a list of "<<n<<" integers"<<endl;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
min=minindex(a,n);//Passing(as parameters)array and its size
cout<<"Minimum element is present at index "<<min;
cout<<endl;
return 0;
}
17 September 2018
C++ program on passing array and its size as parameters
Subscribe to:
Post Comments (Atom)
To convert from Upper case to lowercase(A to a)
//converting from Upper to lower(A to a) import java.util.*; class case { public static void main(String args[]) { System.out.pr...
-
//C++ program to calculate x^n #include<iostream> using namespace std; int main() { int n,x,k; cout<<...
-
//Program to calculate LCM of two(2) numbers #include<iostream> using namespace std; int main() { int a,b,max,lcm; cout<...
-
//Program to calculate area of circle using SWITCH statement import java.util.*; class switch1 { public static void main(String a...
No comments:
Post a Comment