C Sharperror

C #error

Let's explore a basic illustration of employing the #error preprocessor directive.

Example

Example

#include<stdio.h>
#include <math.h>

#ifndef __MATH_H

#error First include then compile

#else

void main(){

    float a;

    a=sqrt(7);

    printf("%f",a);

}

#endif

Output:

Output

Compile Time Error: First include then compile

However, when you include math.h, it does not produce an error.

Example

Example

#include<stdio.h>

#include<math.h>

#ifndef __MATH_H

#error First include then compile

#else

void main(){

    float a;

    a=sqrt(7);

    printf("%f",a);

}

#endif

Output:

Output

2.645751

Input Required

This code uses input(). Please provide values below: