Program structure in programming languages refers to the basic organization and layout of code within a program.
It includes the syntax and semantics of the language, as well as conventions and best practices for writing code that is easy to read, maintain, and debug.
Creating a C program is like assembling a jigsaw puzzle where each piece contributes to the final picture. The 'pieces' in this case are the different components of the C program, all working together to create a complete, functional software. Let's embark on an architectural tour of a C program and understand how these pieces fit together.
Just like how every human being has a defined physical structure, with a head, neck, torso, and limbs, almost everything else has a structure as well. Programming languages are no exception - each one has a specific structure that must be adhered to while writing code.
In particular, the structure of a C program can be broken down into multiple parts, each with its own purpose. Following this structure can help make the program easier to read, modify, and document, as well as ensure consistency in formatting.
The structure of a C language program is the basic framework that every C program follows. The structure of a C program consists of several components or parts.
- Documentation
- Preprocessor Directives
- Header Files or Link
- Global's
- Functions Declaration
- Main function
- Functions Definition
/********************************************************************
File Information:
Filename: main.c
Author: XYZ
Created: DDMMYY
Description: XYZ
********************************************************************/
#ifndef PI
#define PI 3.14
#endif
#include
int variable_x;
int variable_y;
void foo(void);
int main() {
return 0;
}
void foo(void) {
printf("Function Foo");
}