Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int x , y , i , n , a[10];
- cout<<"Enter the number of values : ";
- cin>>n;
- for(i=0;i<n;i++)
- {
- cout<<"Enter the value number "<<i+1<<" : ";
- cin>>a[i];
- }
- x=a[0];
- for(i=0;i<n;i++)
- {
- if(a[i]<x)
- {
- x=a[i];
- }
- }
- if(a[0]!=x)
- {
- y=a[0];
- }
- else
- {
- y=a[1];
- }
- for(i=0;i<n;i++)
- {
- if(a[i]==x)
- {
- i=i+1;
- }
- if(a[i]<y)
- {
- y=a[i];
- }
- }
- cout<<endl<<"The smallest two values are "<<x<<" and "<<y;
- }
Advertisement
Add Comment
Please, Sign In to add comment