Answer:
The program to this question as follows:
Program:
#include<iostream> //include header file.
using namespace std; //using name space.
int main() //main function.
{
int n,i,key; //define variable.
int a[n]; //define array
cout<<"Enter size of array :"; //message.
cin>>n; //input number from user.
cout<<"Enter array elements :"; //message
for(i = 0;i<n;i++) //loop
{
cin>>a[i]; //input array elements
}
cout<<"Enter a number:"; //message
cin>>key; //input number.
for(i = 0;i<n;i++) //loop
{
if(a[i]<=key) //if block
{
cout<<a[i]<<"\n "; //print array elements
}
}
return 0;
}
Output:
Enter size of array :7
Enter array elements :5
50
50
75
100
200
140
Enter a number:100
5
50
50
75
100
Explanation:
The description of the above program as follows: