/*
let we have 2,5,1,7,9
1st small item is 1
2nd small item is 2.
*/
#include<iostream.h>
#include<conio.h>
void main()
{
int ar[5],i;
cout<<"Enter array elements:";
for(i=0;i<5;i++)
{
cin>>ar[i];
}
cout<<"Elements are:\n";
for(i=0;i<5;i++)
{
cout<<ar[i]<<"\t";
}
int min=ar[0];
for(i=0;i<5;i++)
{
if(ar[i]<ar[0])
min=ar[i];
}
cout<<"\nFirst minimum number is:"<<min;
for(i=0;i<5;i++)
{
if(ar[i]==min)
{
ar[i]=32767;
}
}
int min1=ar[0];
for(i=0;i<5;i++)
{
if(ar[i]<ar[0])
{
min1=ar[i];
}
}
cout<<"\nsecond minimum number is:"<<min1;
getch();
}
Output
let we have 2,5,1,7,9
1st small item is 1
2nd small item is 2.
*/
#include<iostream.h>
#include<conio.h>
void main()
{
int ar[5],i;
cout<<"Enter array elements:";
for(i=0;i<5;i++)
{
cin>>ar[i];
}
cout<<"Elements are:\n";
for(i=0;i<5;i++)
{
cout<<ar[i]<<"\t";
}
int min=ar[0];
for(i=0;i<5;i++)
{
if(ar[i]<ar[0])
min=ar[i];
}
cout<<"\nFirst minimum number is:"<<min;
for(i=0;i<5;i++)
{
if(ar[i]==min)
{
ar[i]=32767;
}
}
int min1=ar[0];
for(i=0;i<5;i++)
{
if(ar[i]<ar[0])
{
min1=ar[i];
}
}
cout<<"\nsecond minimum number is:"<<min1;
getch();
}
Output
No comments:
Post a Comment