//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...
-
//Program to find largest and smallest in a list of numbers import java.util.*; class largesmall { public static void main(Str...
-
//Program to print multiplication table up to n numbers import java.util.*; class mtable { public static void main(String args[])...
-
//Program to find LCM of two(2) numbers. import java.util.Scanner; class lcm { public static void main(String args[]) { ...
No comments:
Post a Comment