0% found this document useful (0 votes)
6 views9 pages

C Basics

Uploaded by

Raghu M E
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

C Basics

Uploaded by

Raghu M E
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

BASIC STRUCTURE OF C PROGRAM

 C program can be viewed as a group of building blocks called functions.


 A function is a subroutine that may include one or more statements.

Fig: An overview of C program


.

The documentation section consist of set of comment lines giving name to program.
Link section provides instruction to the compiler to link functions to system library.
In global declaration section contains variables that are declared outside of all
functions.
Every C program must have main() function section.
The subprogram section contains all user defined functions that are called in main
function.
PROGRAMMING STYLE
Unlike some other programming language C is free_form_language. That is, C compiler

does not care, where on the line we begin typing.


C program statements are written in lowercase letters. Uppercase letters are used only

for symbolic constants.


Braces, group program statements together and mar the beginning and end of functions.

A proper indentation of braces and statements would make a program easier to read and

debug.
• The statements
a = b;
x = y + 1;
z = a + 1;
Can be written in one line as:
a = b; x = y +1; z = a+ x;
• The program: main()
{
printf(“Hello C”);
}
May be written in one line as
main( ) {printf(“Hello C”)};
EXECUTING A ‘C’ PROGRAM
 Executing a C program involves series of steps. They are:

1. Creating the program.

2. Compiling the program.

3. Linking the program with functions that are needed from the C library.

4. Executing the program


Process of compiling and running a C program
1. Creating the program
Once we load the UNIX operating system into the memory, the computer s ready to

receive program.
The program must be entered into a file. File name can consist of letters, digits and

special characters, followed by a dot and the letter c.


Examples are: hello.c

program.c
 The file is created with the help of text editor, either ed or vi.
COMPILNG THE PROGRAM
Let us assume that the source program has been created in a file named hello.c. Now
the program is ready for compilation.
The compilation command to achieve this under UNIX is
cc hello.c
EXECUTING A PROGRAM
Execution is a simple task. The command
a. out
would load the executable object code into memory and execute the instructions.
MULTIPLE SOURCE FILE
 To compile and link multiple source program files, we must append all the fule names to the
cc command
cc filename-1.c….filename-n.c
 These files will be separately compiled into object files called
filename-i.o

Fig: Compilation of multiple files.

You might also like