← Back to Codes
C

Arithmetic Macros

Performs arithmetic operations using preprocessor #define macros.

arithmetic_macros.c
#include <stdio.h>
#define ADD(a,b) a+b
#define SUB(a,b) a-b
#define MULTIPLY(a,b) a*b
#define DIVIDE(a,b) a/b
int main()
{
    printf("INSTRUCTIONS: Demonstrates macro usage. No user input required.\n");
    int a=10,b=5;
    printf("addition value is %d\n",ADD(a,b));
    printf("Sub value is %d\n",SUB(a,b));
    printf("multiply value is %d\n",MULTIPLY(a,b));
    printf("divide value is %d\n",DIVIDE(a,b));
    return 0;
}

Arithmetic Macros — Free C Code Example

Performs arithmetic operations using preprocessor #define macros. This free code example is available in C and can be copied and run immediately — no account or signup required. Use the language tabs above to switch between implementations.

How to Use This Code

  1. Select your language — click the language tab (C, Java, C++, or Python) above the code viewer.
  2. Copy the code — use the copy button in the top-right corner of the code block.
  3. Run it — paste into a file with the correct extension (.c, .java, .cpp, .py), compile, and run using your terminal or IDE.
  4. Follow the on-screen instructions in the terminal to provide any required inputs.

Frequently Asked Questions

What does this program do?

Performs arithmetic operations using preprocessor #define macros.

Which languages is it available in?

Available in C. Switch between implementations using the tabs at the top of the code viewer.

How do I run this code?

Copy the code, save it with the right file extension (.c, .java, .cpp, or .py), then compile or run it with your installed compiler or interpreter (GCC, JDK, G++, Python 3).

Is this code free?

Yes — free to view, copy, and use. No account required.

← All Code Examples · Free Tools · Play Games · Blog