Macro in C Language

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

  • Author Replies
    • #53663

      What is Macro in C Language with an Example?

    • #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;
      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))

Viewing 1 reply thread

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


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.


Copyright 2016-2024 Smart Mentors. All Rights Reserved.



Sign up now to Become An Instructor

    Register your Interest

      cf7captchaRegenerate Captcha