Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Explanation of the Programming Code:

#include <stdio.h>

/*header file stdio.h contains prototypes of the library functions

printf(), and scanf(); the header file must be included using

preprocessor directive #include before the functions are called in

the program*/

int main(){

/*all C program must have a main() function with return type void

or int; here there is no parameter of the main() function and it

14 ◾ Learn Programming with C

returns an integer; opening curly brace specifies start of the

main() function and no statement before that curly brace is executed

by the compiler*/

int num;

/*an integer type variable is declared; required memory spaces

are allocated for it*/

printf("Please enter an integer value: ");

/*this displays the text as it is in the double quotations on

the screen*/

scanf("%d", &num);

/*scanf() is an input function that reads an integer from the

input terminal and stores it in the memory location reserved

for the num; hence, the address operator & is used before the

variable name*/

printf("You have entered %d.", num);

/*the text inside the double quotes is displayed as it is on

the screen, except for the value of num replaces the format

specifier %d*/

return 0;
/*0 is returned as it is the standard for the successful

execution of the program*/

/*the closing curly brace specifies the end of the main() function’s

body, as well as the program’s end; after that curly brace, no

statement is executed*/

You might also like