You're working on a C program that must adapt to different operating systems. How can preprocessor directives be used to ensure that the right code is compiled for the right operating system?

  • By using the 'if-else' statement
  • By using 'while' loops
  • By using 'ifdef' and 'ifndef'
  • By using 'for' loops
Preprocessor directives, such as 'ifdef' and 'ifndef,' can be used to conditionally compile code based on the target operating system. This ensures that the correct code is included for each OS. Options a, b, and d do not relate to OS-specific compilation.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *