Programs Collections

 Write a macro to find smallest from two given numbers.

#include <iostream>

using namespace std;

#define MIN(x,y) (x<y?x:y)

int main() {

    int x = 10, y =12, z = 34;

    cout<<"Min ="<<MIN(x,MIN(y,z));

    return 0;

}

Comments

Popular posts from this blog

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given sum.

Print all subsets of given size of a set

[17 Feb 2020] Given an array of integers, find the nearest smaller number for every element such that the smaller element is on left side.