STRUCTURE
OF
‘C’ PROGRAM
‘C’ Program is a collection of
one or more function, Every
function is a collection of
statement perform some
specific task.
//comment
preprocessor directive
global variables
main()
{
local variable
statements
}
function1()
{
local variable
statements
}
function2()
{
local variable
statements
}
.
.
functionN()
{
local variable
statements
}
• Comments can be place anywhere in a
program and are enclose between the
delimiters.
• Comments are generally used for
documentation. Comments ignore by
compiler.
Comments are-
i) Single line comments
ii) Multi-line comments
//ADDITION PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=6;
printf(“%d + %d = %d”,a,b,(a+));
getch();
}
/* ADDITION PROGRAM
this is multi-line comment
all three lines ignore by compiler */
#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=6;
printf(“%d + %d = %d”,a,b,(a+));
getch();
}
Preprocessor directives are process through
preprocessor before the ‘C’ Source code passes
through compiler.
the commonly used preprocessor directives are-
#include and #define
* the #include is used for including the
header files.
* the # define is used to define symbolic
constant and macros.
Commonly used header files in #include preprocessor
directives are-
#include<stdio.h>
#include<conio.h>
These header files are used by the beginners and the
programmers.
# is a special symbol which is requested to compiler.
The nature of # is to request, which is used to request for the
compiler for the specific work.
For example- in mobiles-*123# if we include # with any number
then it run a USSD code or request.
If we not use # then with any number calling start.
You can try-
Dial any number with * and # in mobile then you find a code
running, it doesn’t make a call, it request.
Dial- *2345# or Dial- *12345* you find the difference.
* Now include means to include something
* Include means – add, insert or put in etc.
*Means that # request to include something.
* The something is <stdio.h> header file.
* Stdio.h means std stands for standard, io stands for
input output, and .h is the extension of header file.
Means that #include<stdio.h> is the preprocessor
directive which requests to include/add/ insert the
standard input output header file.
printf(); // used to print statements
scanf(); //used to get input from user
These are the basic function which is
used for beginner of the ‘C’
Programming.
The alternate also available of these
functions, it will discuss later.
The work of #include is same, but the <conio.h> is
differ from the <stdio.h>
conio.h stands for console input output header file.
Function of <conio.h>
clrscr(); // to clear output screen
getch(); // to hold the output screen
conio.h is basically work for the output screen.
ankushrghv@gmail.com
 Every ‘C’ Program has one or more
functions.
 If a program has only ONE Function then
it must be main().
 Execution of every ‘C’ program start with
main() function. It has two part,
declaration of local variables and
statements.
 The scope of the local variables to that
function only.
 Statements in the main() function are
executed one by one.
 Library Function
(also called built-in function.
Eg- scanf(), printf(), gets(), puts() etc.)
 User-Defined Functions
(these are the functions
which are created by the C
Programmer)
1. Function Declaration
2. Function Definition
3. Function Calling
return type function name();
void add(int a, int b);
SYNTAX-
EXAMPLE
-
return type function name()
{
Function body;
}
void add(int a, int b)
{
printf(“add function with parameter”);
}
SYNTAX-
EXAMPLE
-
Function Definition
function_name();
void add(5,7);
SYNTAX-
EXAMPLE
-
 The characters that are used in ‘C’ Program
are ‘C’ Character set. Which are given below-
 Alphabets- A,B,C,D,E,…………………..Z
a,b,c,d,e,f,……………………z
 Digits- 0,1,2,3,4,5,6,7,8,9
 Special character
Symbols Name Symbols Name Symbols Name
+ Plus ) Right
parenthesis
? Question
Mark
* Astrisk { Left curly
braces
& Ampersand
 Backward slash } Right curly
braces
@ At the rate
/ Forward slash [ Left bracket $ Dollar sign
< Less than ] Right Bracket ` Tilde sign
> Greater than , Comma - Minus,
Hyphen
( Left parenthesis : Colon % Percentage
= Equal sign ; Semi-colon | Vertical bar
. Period ‘ ‘ Single
Quotes
^ Caveat sign
“ “ Double quotes ! Exclamation # Hash
ankushrghv@gmail.com

C structure

  • 2.
  • 3.
    ‘C’ Program isa collection of one or more function, Every function is a collection of statement perform some specific task.
  • 4.
    //comment preprocessor directive global variables main() { localvariable statements } function1() { local variable statements } function2() { local variable statements } . . functionN() { local variable statements }
  • 6.
    • Comments canbe place anywhere in a program and are enclose between the delimiters. • Comments are generally used for documentation. Comments ignore by compiler. Comments are- i) Single line comments ii) Multi-line comments
  • 7.
    //ADDITION PROGRAM #include<stdio.h> #include<conio.h> void main() { inta=5,b=6; printf(“%d + %d = %d”,a,b,(a+)); getch(); }
  • 8.
    /* ADDITION PROGRAM thisis multi-line comment all three lines ignore by compiler */ #include<stdio.h> #include<conio.h> void main() { int a=5,b=6; printf(“%d + %d = %d”,a,b,(a+)); getch(); }
  • 10.
    Preprocessor directives areprocess through preprocessor before the ‘C’ Source code passes through compiler. the commonly used preprocessor directives are- #include and #define * the #include is used for including the header files. * the # define is used to define symbolic constant and macros.
  • 11.
    Commonly used headerfiles in #include preprocessor directives are- #include<stdio.h> #include<conio.h> These header files are used by the beginners and the programmers.
  • 12.
    # is aspecial symbol which is requested to compiler. The nature of # is to request, which is used to request for the compiler for the specific work. For example- in mobiles-*123# if we include # with any number then it run a USSD code or request. If we not use # then with any number calling start. You can try- Dial any number with * and # in mobile then you find a code running, it doesn’t make a call, it request. Dial- *2345# or Dial- *12345* you find the difference.
  • 13.
    * Now includemeans to include something * Include means – add, insert or put in etc. *Means that # request to include something. * The something is <stdio.h> header file. * Stdio.h means std stands for standard, io stands for input output, and .h is the extension of header file. Means that #include<stdio.h> is the preprocessor directive which requests to include/add/ insert the standard input output header file.
  • 14.
    printf(); // usedto print statements scanf(); //used to get input from user These are the basic function which is used for beginner of the ‘C’ Programming. The alternate also available of these functions, it will discuss later.
  • 15.
    The work of#include is same, but the <conio.h> is differ from the <stdio.h> conio.h stands for console input output header file. Function of <conio.h> clrscr(); // to clear output screen getch(); // to hold the output screen conio.h is basically work for the output screen.
  • 19.
  • 22.
     Every ‘C’Program has one or more functions.  If a program has only ONE Function then it must be main().  Execution of every ‘C’ program start with main() function. It has two part, declaration of local variables and statements.  The scope of the local variables to that function only.  Statements in the main() function are executed one by one.
  • 23.
     Library Function (alsocalled built-in function. Eg- scanf(), printf(), gets(), puts() etc.)  User-Defined Functions (these are the functions which are created by the C Programmer)
  • 24.
    1. Function Declaration 2.Function Definition 3. Function Calling
  • 25.
    return type functionname(); void add(int a, int b); SYNTAX- EXAMPLE -
  • 26.
    return type functionname() { Function body; } void add(int a, int b) { printf(“add function with parameter”); } SYNTAX- EXAMPLE - Function Definition
  • 27.
  • 29.
     The charactersthat are used in ‘C’ Program are ‘C’ Character set. Which are given below-  Alphabets- A,B,C,D,E,…………………..Z a,b,c,d,e,f,……………………z  Digits- 0,1,2,3,4,5,6,7,8,9  Special character
  • 30.
    Symbols Name SymbolsName Symbols Name + Plus ) Right parenthesis ? Question Mark * Astrisk { Left curly braces & Ampersand Backward slash } Right curly braces @ At the rate / Forward slash [ Left bracket $ Dollar sign < Less than ] Right Bracket ` Tilde sign > Greater than , Comma - Minus, Hyphen ( Left parenthesis : Colon % Percentage = Equal sign ; Semi-colon | Vertical bar . Period ‘ ‘ Single Quotes ^ Caveat sign “ “ Double quotes ! Exclamation # Hash
  • 31.