0% found this document useful (0 votes)
18 views

Lecture 4 Structure of C and Variables in C

C language notes

Uploaded by

skc722768
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Lecture 4 Structure of C and Variables in C

C language notes

Uploaded by

skc722768
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Structure of C and Data

Types used in C
Santosh Sharma
Structure of C Program
Example
1. Documentation Section
• It is the section in which you can give comments to make the program more
interactive.
2. Preprocessor directives Section
• This section involves the use of header files that are to included necessarily
program.
3. Definition section
• This section involves the variable definition and declaration in C.
4. Global declaration Section
• This section is used to define the global variables to be used in the programs,
that means you can use these variables throughout the program.
5. Function prototype declaration section
• This section gives the information about a function that includes, the data
type or the return type, the parameters passed or the arguments.
6. Main function
• It is the major section from where the execution of the program begins. The
main section involves the declaration and executable section.
7. User-defined function section
• User define are defined that fulfills a particular requirement.
Files used in C program

Files used in C Program

Source File Header File Object File Executable File


• Source file(.c): These files contain function definitions, and the entire
program logics, these files are human readable and by convention their
names end with .c.
• Header file(.h): These files contain function prototypes and various pre-
processor statements. They are used to allow source code files to access
externally-defined functions and by convention their names end with .h.
• Object file(.o): These files are produced as the output of the compiler. They
consist of function definitions in binary form, but they are not executable by
themselves and by convention their names end with .o.
• Binary executables file(.exe): These files are produced as the output of a
program called a “linker“. The linker links together a number of object files
to produce a binary file that can be directly executed. It contains symbols
that the linker can extract from the archive and insert into an executable as
it is being built. And by convention their names end with .exe in windows.
Compilation
and
Execution of
C program
Variables
• A variable in C language is the name associated with some memory
location to store data of different types.
• There are many types of variables in C depending on the scope,
storage class, lifetime, type of data they store, etc.
• A variable is the basic building block of a C program that can be used
in expressions as a substitute in place of the value it stores.
• C Variable Syntax
Rules for Naming Variables in C

1.A variable name must only contain alphabets, digits, and


underscore.
2.A variable name must start with an alphabet or an underscore
only. It cannot start with a digit.
3.No whitespace is allowed within the variable name.
4.A variable name must not be any reserved word or keyword.
Data Types

You might also like