Features of C program and Structure of C program With Simple Example and Explanation of parts of C program
Size: 983.75 KB
Language: en
Added: Dec 10, 2017
Slides: 12 pages
Slide Content
Computer Programming And Utilization
FEATURES OF ‘C’ Denis Ritchie developed ‘C’ language . Previous version was known as ‘B’ language. Important feature of ‘C’ language is it is portable, portability we mean that program can be run on any hardware machine. Other features are it is modular language , supports bit-wise operations and does not provide input-output statement. The bit-wise operations allow the programmer to do the operations on data bit by bit , which is a feature of machine language. Because of this facility ,’C’ is known as MIDDLE LEVEL LANGUAGE
The other important feature of ‘c’ program is that it is modular . The large problem is divided into small sub problems. Each module is individually approached as separate sub problem and solution is found. Then all the module are put together and the solution of the large problem is derived . Because of the modularity support ,’c’ language is also called as structured programming language
STRUCTURE OF A ‘C’ PROGRAM Every ‘C’ program has to follow specific structure of ‘c’ program must have at least one function called main(). The main() function has to control over the other part of program. Execution of the program start from the main() function. The ‘C’ program structure is given below:-
STRUCTURE OF A ‘C’ PROGRAM Documentation Header file section Constants and Global variables main () { Statement(s) ) User defined functions and procedures with their body
STRUCTURE OF A ‘C’ PROGRAM Program: /*Write a program print the message Hello !*/ #include< stdio.h > void main( ) { printf (“Hello !”); }
STRUCTURE OF A ‘C’ PROGRAM Output : Hello !
STRUCTURE OF A ‘C’ PROGRAM The line #include< stdio.h > includes the header file named as stdio.h . This file is necessary to be included in our program whenever we are doing input–output operations. The next line is void main() which includes the main() function. The void keyword indicates it does not return any value of operating system.
Within the brackets {and} the body of main() function is written. The symbol { indicates start of the main function, while symbol } for the end of the program. The satement printf (“Hello!”);actually prints the Hello ! message on the screen . In ‘C’ all the statements must be terminated by semicolon’;’ symbol.That is the reason why there is semicolon after printf (“Hello!”).