Follow Me

Preprocessor exercises in C Programming in C

  • Program output 4: Give the output on the screen of the following program #include <stdio.h>#define PRINT(i) printf("value = %d\n", i)int main(){     int x = 03, y = 02 , z = 01;     PRINT(x | y & z);      PRINT(x | y & - z);      PRINT(x ^ y ...
  • Half the input value: Write a preprocessor command that halves its input value....
  • Average of 5 integers: Write a preprocessor command that calculates the average of 5 integers....
  • Maximum of 2 integers: Write a preprocessor command that calculates the maximum of 2 integers....
  • Sum of 3 integers: Write a preprocessor command that calculates the sum of 3 integers....
  • Square of an integer: Write a preprocessor command that calculates the square of an integer....
  • Hello People: Write a preprocessor command that prints on the string its parameter...
  • Using the hashtag operator in macro expansion: Write a preprocessor command that uses the # operator in macro expansion....
  • Using the double hashtag operator in macro expansion: Write a preprocessor command that uses the ## (concatenation operator) operator in macro expansion....
  • Using the defined operator: Write a preprocessor command that uses the defined operator....
  • Using preprocessor directives with header files: Write a preprocessor command that uses preprocessor directives with header files....
  • Using preprocessor directives with undef command: Write a preprocessor command that uses the #undef command....
  • Using preprocessor directives with Predefined Macros: Write a preprocessor command that uses the Predefined Macros __DATE__, __TIME__, __LINE__, and __FILE__....
  • Program output 7: Give the output on the screen of the following program #include <stdio.h> #define PRINT(format,x) printf(#x " = %"#format"\n",x) int main(){     int integer = 5;     char character = '5';     char *string = "5";     PRINT(d, string)...
  • Program output 8: Give the output on the screen of the following program #include <stdio.h> #define PR(x) printf(#x " = %.8g\t",(double)x)#define NL putchar('\n');#define PRINT4(a,b,c,d) PR(a);PR(b);PR(c);PR(d);NL int main(){     double d;     float f;  ...
  • Program output 9: Give the output on the screen of the following program #include <stdio.h> #define PR(x) printf(#x " = %.8g\t",(double)x)#define NL putchar('\n');#define PRINT1(a) PR(a);NL#define PRINT2(a,b) PR(a);PR(b);NL int main(){     double d = 3.2 , x;...
  • Program output 10: Give the output on the screen of the following program #include <stdio.h> #define PRINT(format,x) printf(#x " = %"#format"\t",x)#define NL putchar('\n'); #define PRINT1(f,x) PRINT(f,x);NL#define PRINT2(f,x1,x2) PRINT(f,x1);PRINT1(f,x2)#define...
  • Program output 11: Give the output on the screen of the following program #include <stdio.h> #define PRINT(format,x) printf(#x " = %"#format"\t",x)#define NL putchar('\n'); #define PRINT1(f,x) PRINT(f,x);NL#define PRINT2(f,x1,x2) PRINT(f,x1);PRINT1(f,x2)#define...

Back to the list of exercises