A facile and convenient procedure for the synthesis of 4H-pyrans from aldehydes, malononitrile, and ethyl acetoacetate/acetylacetone and also synthesis of 4H-pyrano[2,3-c]pyrazoles from three-component condensation of aldehydes, malononitrile, and pyrazolone or four-component condensation of aldehydes, malononitrile, ethyl acetoacetate, and hydrazine monohydrate using [bmim]OH as task-specific ionic liquid has been described. The protocol proves to be efficient and environmentally benign in terms of high yields, low reaction times, ease of recovery, and reusability of reaction medium.