PROGRAMMING IN ‘C’
What is meant by programming language?
A programming language is a formal
language which comprises a set of
instructions that produce various kinds
of output.
Most programming languages consist
of instructions for computers.
programming languages are used to create
programs to solve problems
About ‘c’
 Root of all modern languges is ALGOL-algorithmic
language in 1960s
 1967-BCPL-Basic Combined Programming Language
was developed
 Ken thompson created a language ‘B’
 ‘C’ was developed by Dennis Ritche in 1972
 ‘C’ is a structured programming language
STRUCTURE EXPLANATION
Documentation Consists of comments, some description of
the program.
Link Provides instruction to the compiler to Link
function from the library function.
Definition Consists of symbolic constants.
Global declaration Consists of function declaration and global
variables.
main( )
{
Declaration part;
executable part;
}
Every C program must have
main() function which is the starting
point of the program execution.
Subprograms
function 1
function 2
--
function n
User defined functions.
Sample program
/* Program to find the area of a circle using the radius r */
#include <stdio.h> /*link section-*/
#define PI 3.1416 /*definition section*/
float area; /*global declaration*/
main() /*main function starts here*/
{
float r ; /*local variable declaration*/
printf(“nEnter the value for r=”);
scanf(“%f”,&r); /*input statement*/
area = PI *r*r; /*assignment statement*/
printf(“nArea: %.2f", area); /*output statement*/
} /*main fun ends*/
Output:
Enter the value for r =10
The above code will give the following output.
Area: 314.16
C tokens
Tokens-individual words and punctuation marks
 Keyword: reserved words-32 keywords
 E.g static, int,printf,scanf
 Identifier-every c word is classified as either
keyword or identifier
 E.g main,amount
 Constants-fixed values
 Two types
 Numeric constants
 Integer constant ,real constant
 Character constants
 Single character constants, string constants
---continued
 Strings
 Sequence of characters (E.g “welcome”)
 Operators
 8 types of operators
 Arithmetic operator-( +, -,*,/)
 Relational operator-(<,>,<=,>=,==,!=)
 Logical operator (AND &&,OR ||,NOT !)
 Assignment operator(=)
 Increment & decrement operator(++,- -)
 Conditional operator(?,: )
 Bit wise operator (bit wise&, bit wise |)
 Special operator (sizeof)
 Special symbols({ },[ ], ( ) )
Thank you

C programming

  • 1.
    PROGRAMMING IN ‘C’ Whatis meant by programming language? A programming language is a formal language which comprises a set of instructions that produce various kinds of output. Most programming languages consist of instructions for computers. programming languages are used to create programs to solve problems
  • 2.
    About ‘c’  Rootof all modern languges is ALGOL-algorithmic language in 1960s  1967-BCPL-Basic Combined Programming Language was developed  Ken thompson created a language ‘B’  ‘C’ was developed by Dennis Ritche in 1972  ‘C’ is a structured programming language
  • 3.
    STRUCTURE EXPLANATION Documentation Consistsof comments, some description of the program. Link Provides instruction to the compiler to Link function from the library function. Definition Consists of symbolic constants. Global declaration Consists of function declaration and global variables. main( ) { Declaration part; executable part; } Every C program must have main() function which is the starting point of the program execution. Subprograms function 1 function 2 -- function n User defined functions.
  • 4.
    Sample program /* Programto find the area of a circle using the radius r */ #include <stdio.h> /*link section-*/ #define PI 3.1416 /*definition section*/ float area; /*global declaration*/ main() /*main function starts here*/ { float r ; /*local variable declaration*/ printf(“nEnter the value for r=”); scanf(“%f”,&r); /*input statement*/ area = PI *r*r; /*assignment statement*/ printf(“nArea: %.2f", area); /*output statement*/ } /*main fun ends*/ Output: Enter the value for r =10 The above code will give the following output. Area: 314.16
  • 5.
    C tokens Tokens-individual wordsand punctuation marks  Keyword: reserved words-32 keywords  E.g static, int,printf,scanf  Identifier-every c word is classified as either keyword or identifier  E.g main,amount  Constants-fixed values  Two types  Numeric constants  Integer constant ,real constant  Character constants  Single character constants, string constants
  • 6.
    ---continued  Strings  Sequenceof characters (E.g “welcome”)  Operators  8 types of operators  Arithmetic operator-( +, -,*,/)  Relational operator-(<,>,<=,>=,==,!=)  Logical operator (AND &&,OR ||,NOT !)  Assignment operator(=)  Increment & decrement operator(++,- -)  Conditional operator(?,: )  Bit wise operator (bit wise&, bit wise |)  Special operator (sizeof)  Special symbols({ },[ ], ( ) )
  • 8.