C Language Tutorials by Ghulam Murtaza Dahar - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Output

4 day

You can write any program in C language without the help of enumerations but, enumerations helps in writing clear codes and simplify programming.

C Programming Preprocessor and Macros

Preprocessor extends the power of C programming language. Line that begin with # are called preprocessing directives.

Use of #include

Let us consider very common preprocessing directive as below:

#include <stdio.h>

Here, "stdio.h" is a header file and the preprocessor replace the above line with the contents of header file.

Use of #define

Preprocessing directive #define has two forms. The first form is:

#define identifier token_string

token_string part is optional but, are used almost every time in program.

Example of #define

#define c 299792458 /*speed of light in m/s */

The token string in above line 2299792458 is replaced in every occurance of symbolic constant c.

C Program to find area of a cricle. [Area of circle=πr2]

#include <stdio.h>

#define PI 3.1415

int main(){

int radius;

float area;

printf("Enter the radius: ");

scanf("%d",&radius);

area=PI*radius*radius;

printf("Area=%.2f",area);

return 0;

}

Find Your Next Great Read

Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.

Showing results for ""

Popular searches:

Romance Mystery & Thriller Self-Help Sci-Fi Business