A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Define Macro PRINT to print given integer argument in C | C preprocessor programs
Q:

Define Macro PRINT to print given integer argument in C | C preprocessor programs

0

Define Macro PRINT to print given integer argument in C | C preprocessor programs

As we have discussed in the last post (how to use printf in function like macro?) that we can use printf() in Macros.

Here, we have to define a Macro that will accept an argument and print it by using printf() function.

Macro definition:

    #define PRINT(val) (printf("value is: %d\n",val))

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Example:

#include <stdio.h>

#define PRINT(val) (printf("value is: %d\n",val))

//Main code
int main(){
	
	PRINT(10);
	PRINT(100);
	PRINT(-12);
	PRINT(0);
	
	return 0;	
}

Output:

    value is: 10
    value is: 100
    value is: -12
    value is: 0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now