Professional Documents
Culture Documents
C Programming Tutorial
C Programming Tutorial
When you have multiple files and you define a global variable or function, which will be
used in other files also, then extern will be used in another file to give reference of defined
variable or function. Just for understanding, extern is used to declare a global variable or
function in another file.
The extern modifier is most commonly used when there are two or more files sharing the
same global variables or functions as explained below.
int count ;
extern void write_extern();
main()
{
write_extern();
}
void write_extern(void)
{
count = 5;
printf("count is %d\n", count);
}
Here, extern keyword is being used to declare count in the second file where as it has its
definition in the first file, main.c. Now, compile these two files as follows:
This will produce a.out executable program, when this program is executed, it produces
the following result:
TUTORIALS POINT
Simply Easy Learning Page 24
CHAPTER
10
Decision Making in C
D ecision making structures require that the programmer specify one or more
Following is the general form of a typical decision making structure found in most of the
programming languages:
C programming language assumes any non-zero and non-null values as true, and if it is
either zero or null, then it is assumed as false value. C programming language provides
following types of decision making statements.
TUTORIALS POINT
Simply Easy Learning Page 35
while loop in C
A while loop statement in C programming language repeatedly executes a target
statement as long as a given condition is true.
Syntax
The syntax of a while loop in C programming language is:
while(condition)
{
statement(s);
}
When the condition becomes false, program control passes to the line immediately
following the loop.
Flow Diagram
TUTORIALS POINT
Simply Easy Learning Page 46