Introduction
C programming language is a computer programming language and it is an essential programming language, C was created in 1970 by Bell Labs by Ken Thompson and Dennis Ritchie. It was utilized to create framework applications. It was created as a framework programming language for composing working frameworks. C programming is considered the reason for other programming languages.
Java, PHP, JavaScript, and the linguistic structure of different languages are mainly based on C. This design suggests that any program can only be written in this framework, but composing a C program in some frameworks can cause a coordinate error. There are three standards for the C programming language ANSI C, ISO C, and the standard C. C is accessible for a wide range of kinds of computers, this is the reason C is called a "convenient" language.
Structure of C program
1. Header Section
The file with the header file extension .h is displayed. Some C header files such as stddef.h, stdint.h, stdio.h, math.h, etc. For Example #include<stdio.h>, #include<math.h>.
2. Defination Section
That define a veriable value in this section. That define different constants. That value can’t be changed in program.
For example #define abc 10, #define Pi 3.14;
3. Global Declaration
Global declaration
section use to declare global veriable. Global veriable are search veriable
which can be access everyehere in the program. This part of the code where the
global variables are declared in this section. All the global variables used
are revealed in this section, user-defined functions are also revealed in this
section.
For example
- float per(float r);
- int a=7;
4. Main()
Main function section
contain to parts 1. Declaration parts, 2. Execution part. Declaration part is all the
variables. Execution part that use opening
bracks{ and ends with closing bracks }. The main () function is declared
compulsory.
- Main()
- {
- Variable Declaration (Declaration part);
- Body Section
- Return;
- }
Example:
- #include<math.h>
- int main()
- {
- int a=10;
- printf ("Hello…..\n");
-
printf(" %d", a);
- return 0;
- }
- #include<stdio.h> prepares
standard input/output tools for program use,and this allows the text to be
displayed.
- int main () is called the main
functionof this section, where the first code in C program begins to be
written.
- printf ("Hello….\n"); This
text shows, in this case "Hello….." With a new line at the end.
- Return: That return the value.
Sub program section
In this section of the program the user defines all the tasks he has assigned in this section.
- int return_value(int b)
- {
- return b;
- }
Sample of the Program
- #include<stdio.h> // header section
- #define
a 15; //defination
section
int sum(int b);
//global declarationint main() //main function
{
- printf("
Enter any value: ");
- scanf("%d",&
b
); - printf("Sum
is: %d",sum(
b
)); - return 0;
- }
- Int sum(int b) //sub program
- {
- return a+b;
- }
0 Comments