-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacros.cpp
More file actions
44 lines (33 loc) · 789 Bytes
/
macros.cpp
File metadata and controls
44 lines (33 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//C++ program to illustrate macros
#include <iostream>
using namespace std;
// Macro definition
#define AREA(l, b) (l * b)
#define ELE 1, \
2, \
3
#define min(a, b) (((a) < (b)) ? (a) : (b))
int main()
{
// Given lengths l1 and l2
int l1 = 10, l2 = 5, area;
// Find the area using macros
area = AREA(l1, l2);
// Print the area
cout << "Area of rectangle"
<< " is: "<<
area <<endl;
int arr[] = { ELE };
// Print elements
printf("Elements of Array are:\n");
for (int i = 0; i < 3; i++) {
cout << arr[i] << ' ';
}
int a = 18;
int b = 76;
cout << endl;
cout << "Minimum value between "
<< a << " and " << b
<< " is: " << min(a, b);
return 0;
}