Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


C Programming Code Examples

Learn C Language

#ifdef Directive in C Programming Language

#ifdef Directive in C
This directive is the simplest conditional directive. This block is called a conditional group. The controlled text will get included in the preprocessor output iff the macroname is defined. The controlled text inside a conditional will embrace preprocessing directives. They are executed only if the conditional succeeds. You can nest these in multiple layers, but they must be completely nested. In other words, '#endif' always matches the nearest '#ifdef' (or '#ifndef', or '#if'). Also, you can't begin a conditional group in one file and finish it in another.
Syntax for #ifdef Directive in C
#ifdef MACRO controlled text #endif /* macroname */
Note: The #ifdef directive must be closed by an #endif directive.
/* the #ifdef directive allows for conditional compilation. The preprocessor determines if the provided macro exists before including the subsequent code in the compilation process. */ #include<stdio.h> #define PI 3.14 int compute_area(int radius) { return 3.14*radius*radius; } void main() { int area=0, radius=10; #ifdef PI area = compute_area(radius); #else area = 200; #endif printf("\nArea of circle: %d", area); }








C In Statistics Maths, a mode is a value that occurs the highest numbers of time. Example assume a set of values 8, 5, 4, 7, 8. mode of this value set is 8 as it appears more than any


Write a C program to 'Replace all Occurrence' of a character with another in a string using a Function. 'Input a string' from user, store it in some variable say str. Input old character and

Program accepts a string and checks whether a given string is 'Palindrome'. Take a string as input & store it in the array string[]. Store the same string into the another array 'reverse_s'