A
aarklon
Hi all,
the following is a question which i found on a book,the reader is asked
to predict the output
#include<stdio.h>
#define SUM(F_NAME,DATA_TYPE,L)\
void F_NAME(DATA_TYPE x,DATA_TYPE y)\
{\
DATA_TYPE add;\
add = x + y;\
printf("The summation of "#DATA_TYPE""\
" values is %"#L"\n",add);\
}
void sum_int(int,int);
void sum_float(float,float);
int main(void)
{
sum_int(3,5);
sum_float(3.1,5.3);
return 0;
}
SUM(sum_int,int,d);
SUM(sum_float,float,f);
Output is given as
the summation of int values is 8
the summation of float values is 8.400000
But I am getting the error as # operator is not followed by a macro
argument name.
can anybody suggest ways to fix this code??
the following is a question which i found on a book,the reader is asked
to predict the output
#include<stdio.h>
#define SUM(F_NAME,DATA_TYPE,L)\
void F_NAME(DATA_TYPE x,DATA_TYPE y)\
{\
DATA_TYPE add;\
add = x + y;\
printf("The summation of "#DATA_TYPE""\
" values is %"#L"\n",add);\
}
void sum_int(int,int);
void sum_float(float,float);
int main(void)
{
sum_int(3,5);
sum_float(3.1,5.3);
return 0;
}
SUM(sum_int,int,d);
SUM(sum_float,float,f);
Output is given as
the summation of int values is 8
the summation of float values is 8.400000
But I am getting the error as # operator is not followed by a macro
argument name.
can anybody suggest ways to fix this code??