# Program to find Minimum Positive even number

Find for the lowest positive even integer.

You can input numbers whenever you want. But when you a negative number, it will stop asking and find the lowest positive even integer.

Logic:

– We assume that the minimum positive even number is 100000 and the user enters numbers which are less than 100000.

– For this we create a variable min and initialize it to 100000.

– Now take the input of numbers using an infinite loop.

– For each number(n)

– Check if n is greater than 0 ie positive. (n>0)

– Check if n is even(n%2==0)

– Check if n is less than current min.

– If all the above 3 condition is true then make n as current minimum.

– Else if n is negetive then stop by breaking the infinite loop

– if min= 100000 then the user entered the 1st number negetive.

– else print current minimum.

(**NOTE**: The logic works only if user enters numbers less than 100000.)

#include <stdio.h> int main(){ // Assume min to be current minimum value and initialize it to 100000. int n,min=100000; printf("Enter Numbersn"); // Infinite loop. while(1){ scanf("%d",&n); //n>0 -> Positive n%2==0 -> Even n Number is less than current if(n>0 && n%2==0 && n<min){ // Make n as current minimum value min=n; // n<0 -> Negetive }else if(n<0){ // if the 1st number is negetive. if(min==100000) printf("There is no minumum positive even numbern"); else{ // Print current minimum. printf("Minimum Positive even number is: %d",min); } break; } } return 0; }