/* */ Click to Join Live Class with Shankar sir Call 9798158723
Q.) WAP to print all the numbers which are less than given key element from a given array.
    #include < stdio.h>
#include < stdlib.h>


int main(void)

{
	
	int *a,n,i,pos=-1,element;

	printf("Enter size of array:");
	scanf("%d",&n);

	a=malloc(sizeof(int)*n);
	printf("Enter %d Elements:",n);
	for(i=0;i< n;i++)

	{

		scanf("%d",&a[i]);

	}

	printf("Enter a number:");
	scanf("%d",&element);

	printf("Elements less than %d are:\n",element);
	for(i=0;i< n;i++)
	
	{

		if(a[i]< element)
		{
			printf("%d ",a[i]);	
		}
	}

	
	return 0;

}
Output
Sample Input 1:
5 5 7 9 3 1 4
Sample Output 1:
3 1

Sample Input 2:
5 5 7 9 3 1 8

Sample Output 2:
5 7 3 1


Program Explanation


Step 1 : Include header files (#include< stdio.h> and #include < stdlib.h>).

Step 2 : Start with main function with return type.

Step 3 : parenthesis to start and end the program { }.

Step 4 : declare variables with data type i.e, '*a,n,i,pos=-1,element' is an integer type so we use "int" data type.

Step 5 : Use output function printf() to print the output on the screen.

Step 6 : Use input function scanf() to get input from the user.

Step 7 : here, print all the numbers which are less than given key element from a given array ,Enter size of array: scanf function is used to seen the size of array and then printf function was give meassage Enter Elements: after enter element for loop was check the condition for(i=0;i< n;i++), the condition was true value of n will go under the loop and scanf function was seen the a[i] , and the printf function was give a message 'Enter a number:' and scanf function was scan the enter number ,and printf function was give message " Elements less than are: element" after if statement was perform if(a[i]< element) and give output of "a[i]".

Step 8 : using getch() function to hold the screen.