C - Demonstrate the debugging process using preprocessor directive '#define' Code Example

The code for Demonstrate the debugging process using preprocessor directive '#define'

#include <stdio.h>
#define DEBUGMSG

int main() {
  int x = 10, y = 20, sum = 0;

  sum = x + y;

#ifdef DEBUGMSG
  printf("Debug: x: %d, y: %d, sum: %d\n", x, y, sum);

#endif
  x++;
  y++;

#ifdef DEBUGMSG
  printf("Debug: x: %d, y: %d, sum: %d\n", x, y, sum);
#endif

  return 0;
}


/*
Output:
Debug: x: 10, y: 20, sum: 30
Debug: x: 11, y: 21, sum: 30
*/
Code by IncludeHelp, on August 11, 2022 20:03

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.