Forum

Macro in C Language

This thread contains 1 reply, has 2 voices, and was last updated by  Test 8 months ago.

  • Author Replies
  • #53663

    What is Macro in C Language with an Example?


  •  Test
    #53665

    The C preprocessor is a macro preprocessor (enables you to characterize macros) that changes your program before it is compiled. These changes can be the consideration of header record, macro expansions and so on. All preprocessing directives start with a # symbol.

    1) Macros are the identifiers that speak to proclamations or articulations as it were macros are a section of code which is been given a name.
    2) #define directive is utilized to characterize macro.
    3) Example, we have characterized a macro i.e SQUARE(x) x*x.
    4) Here the macro decides the square of the given number.
    5) Macro Declaration: #define name content.

    Example : #define preprocessor
    #include <stdio.h>
    #define PI 3.1415

    int main()
    {
    float radius, area;
    printf(“Enter the radius: “);
    scanf(“%d”, &radius);
    area = PI*radius*radius;
    printf(“Area=%.2f”,area);
    return 0;
    }

    You can likewise characterize macros that work like a function call, known as function like macros. For instance, #define circleArea(r) (3.1415*(r)*(r))


You must be to reply to this thread.Please or . Registration is 100% free.

GET FREE CONSULTATION

Call Us Now For Free Consultation97370 05566

Our experts listen to you patiently and suggest you the right course after conducting a personality profile test. Register your interest below to schedule personality profile test for you.

SUBSCRIBE TO OUR NEWSLETTER

Contact Us

Working Hours

  • Monday9:00 AM – 9:00 PM
  • Tuesday9:00 AM – 9:00 PM
  • Wednesday9:00 AM – 9:00 PM
  • Thursday9:00 AM – 9:00 PM
  • Friday9:00 AM – 9:00 PM
  • Saturday9:00 AM – 9:00 PM
  • SundayClosed
Copyright 2016-2019 Smart Mentors. All Rights Reserved.

Login

FORGOT PASSWORD

Sign up now to Become An Instructor

Register your Interest