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 a Macro to find total number of elements in C
Q:

Define a Macro to find total number of elements in C

0

Define a Macro to find total number of elements in C

We have to define a Macro to find total number of elements in C programming language.

Macro Definition:

    #define ARRAY_LEN(ARRAY_NAME, TYPE)(sizeof(ARRAY_NAME)/sizeof(TYPE))

All Answers

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

Program:

#include <stdio.h>

#define ARRAY_LEN(ARRAY_NAME, TYPE)(sizeof(ARRAY_NAME)/sizeof(TYPE))

int main()
{
	int iArr[10];
	float fArr[5];
	char cArr[50];
	
	printf("Total elements in iArr: %d\n", ARRAY_LEN(iArr, int));
	printf("Total elements in fArr: %d\n", ARRAY_LEN(fArr, float));
	printf("Total elements in cArr: %d\n", ARRAY_LEN(cArr, char));
	
	return 0;
}

Output

Total elements in iArr: 10
Total elements in fArr: 5
Total elements in cArr: 50

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