0% found this document useful (0 votes)
23 views12 pages

C Basics

C is a structured, function-oriented programming language where every instruction must follow predefined syntax. A basic C program structure includes documentation, preprocessing statements, global declarations, a main method that is the starting point, and implementation of user-defined methods. The main method and any other functions contain the actual code to be executed. Preprocessing statements provide instructions to the compiler before compilation.

Uploaded by

Sumit k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views12 pages

C Basics

C is a structured, function-oriented programming language where every instruction must follow predefined syntax. A basic C program structure includes documentation, preprocessing statements, global declarations, a main method that is the starting point, and implementation of user-defined methods. The main method and any other functions contain the actual code to be executed. Preprocessing statements provide instructions to the compiler before compilation.

Uploaded by

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

C Programming Language

Basics
Basics of C Programming?

C is a structured programming language. So every


instruction in a c program must follow the
predefined structure (Syntax).

C is also known as Function Oriented Programming


Language. So every executable statement must
written inside a function.

1
General Structure of a C Program
/* Documentation */

Pre-Processing Statements

Global Declarations

Main method

Used defined methods implementation


2
General Structure of a C Program

Documentation /* Documentation */
- It is used to provide brief information Pre-Processing Statements
of the program. Global Declarations

- This part is written using comments. Main method

- Generally the documentation part does Used defined methods


not executed by compiler & it is implementation
optional part.

3
General Structure of a C Program
Pre-Processing Statements
- It is used to link the header files, /* Documentation */
define the constants, etc... Pre-Processing Statements
Global Declarations

- Every preprocessor statement starts


with hash (#) symbol. Main method

- Every Preprocessor statement tells to Used defined methods


the compiler to perform required implementation

pre-processing before the actual


compilation.
4
General Structure of a C Program
Pre-Processing Statements
- Examples /* Documentation */
#include Pre-Processing Statements
#define Global Declarations
#undef
#ifdef
Main method
#ifndef
#if
#else Used defined methods
#elif implementation
#endif
#error
#pragma
5
General Structure of a C Program
Global Declaration
- This part is used to declare the /* Documentation */
variables which are common for multiple Pre-Processing Statements
methods. Global Declarations

- In this section, we also declare Main method


enumeration, structure, unions,
userdefined methods etc... Used defined methods
implementation

- It is also optional part. According to


our requirement we write this section.
6
General Structure of a C Program
Main method
- main method is the compulsory part for any c /* Documentation */
program. Pre-Processing Statements
- C language is a function oriented programming Global Declarations
language, so every c program must have at least
one function and that must be main. Main method
- Main is a userdefined method which specifies
the starting point of the program execution. Used defined methods
implementation
- Every c program execution starts with main
method and ends with main method itself.

7
General Structure of a C Program
Userdefined Methods
- In this section of the program we write the /* Documentation */
actual code for the userdefined methods. Pre-Processing Statements
- Userdefined methods can be implemented Global Declarations
either before or after the method.
Main method
- If it is implemented after the main then it
must be declared either inside or before the
main method. Used defined methods
implementation
- If it is implemented before the main then the
declaration can be ignored.

8
General Structure of a C Program - Example
/* Program to print a message Hello World! */

#include<stdio.h>

void main()
{

printf(“Hello World!!!!”);

9
Rules for Writing C programs
Every c program must contain exact one main
method
Every executable instruction must end with
semicolon (;)
All the system defined words (Keywords) must
be used in lowercase letters
Every open brace ({) must have the respective
closing brace (})
The variables must be declared in the
declaration section before they are used 10

You might also like