4. C language is one of the most popular
computer language
structured ,
low level ,
machine dependent language
12/11/2015Session-1/Dr.M.karthika 4
5. C programming language was developed in
1972 by Dennis Ritchie at bell laboratories of
AT&T(American Telephone & Telegraph),
located in U.S.A.
It was developed to be used in UNIX
Operating system.
It inherits many features of previous
languages such as B and BPCL.
12/11/2015Session-1/Dr.M.karthika 5
6. Language year Developed By
ALGOL 1960 International Group
BPCL 1967 Martin Richards
B 1970 Ken Thompson
Traditional C 1972 Dennis Ritchie
K & R C 1978 Kernighan & Dennis
Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISO C 1990 ISO Committee
C99 1999 Standardization
Committee
7. C is mother language of all programming
language.
It is system programming language.
It is procedure-oriented programming
language.
It is also called mid level programming
language.
8. There are many features of c language are given below.
1) Simple
2) Machine Independent or Portable
3) Mid-level programming language
4) structured programming language
5) Rich Library
6) Memory Management
7) Fast Speed
8) Pointers
9) Recursion
10) Extensible
9. A sample C Program
#include<stdio.h>
int main()
{
--other statements
// Comments after double slash
}
Friday, December 11, 2015 9
10. Type a program
Save it
Compile the program – This will generate an
exe file (executable)
Run the program (Actually the exe created out
of compilation will run and not the .c file)
In different compiler we have different option
for compiling and running. We give only the
concepts.
Friday, December 11, 2015 10
11. #include <stdio.h> includes the standard input
output library functions.
The printf() function is defined in stdio.h .
#include <conio.h> includes the console input
output library functions.
The getch() function is defined in conio.h file.
void main() The main() function is the entry point
of every program in c language.
The void keyword specifies that it returns no value.
printf() The printf() function is used to print data on
the console.
getch() The getch() function asks for a single
character. Until you press any key, it blocks the screen.
12. The files that are specified in the include section
is called as header file
These are precompiled files that has some
functions defined in them
We can call those functions in our program by
supplying parameters
Header file is given an extension .h
C Source file is given an extension .c
13. This is the entry point of a program
When a file is executed, the start point is the
main function
From main function the flow goes as per the
programmers choice.
There may or may not be other functions
written by user in a program
Main function is compulsory for any C program
14. #include <stdio.h> includes the standard input
output library functions. The printf() function is defined
in stdio.h .
#include <conio.h> includes the console input
output library functions. The getch() function is defined
in conio.h file.
void main() The main() function is the entry point
of every program in c language. The void keyword
specifies that it returns no value.
printf() The printf() function is used to print data on
the console.
getch() The getch() function asks for a single
character. Until you press any key, it blocks the screen.
17. There are two input output function of c
language.
1) First is printf()
2) Second is scanf()
18. printf() function is used for output.
It prints the given statement to the console.
Syntax of printf() is given below:
printf(“format string”,arguments_list);
Format string can be
%d (integer),
%c (character),
%s (string),
%f (float) etc.
12/11/2015Session-1/Dr.M.karthika 18
19. scanf() Function: is used for input. It reads
the input data from console.
scanf(“format string”,argument_list);
20. Input
› scanf(“%d”,&a);
› Gets an integer value from the user and stores it
under the name “a”
Output
› printf(“%d”,a);
› Prints the value present in variable a on the
screen
Friday, December 11, 2015 20
21. Single line comment
› // (double slash)
› Termination of comment is by pressing enter key
Multi line comment
/*….
…….*/
This can span over to multiple lines
Friday, December 11, 2015 21
22. 12/11/2015Session-1/Dr.M.karthika 22
Constant Meaning
‘a’ Audible Alert (Bell)
‘b’ Back Space
‘f’ Form Feed
‘n’ New Line
‘r’ Carriage Return
‘t’ Horizontal Tab
‘v’ Vertical Tab
”’ Single Quote
‘”‘ Double Quote
‘?’ Question Mark
‘’ Backslash
‘0’ Null
Escape Sequences
23. /* Testing the escape sequences */
#include <stdio.h>
int main(void)
{
printf("Testing the escape sequences:n");
printf("-----------------------------n");
/* 3 times audible tone */
printf("The audible bell ---> a aaan");
printf("The backspace ---> b___ bTestingn");
/* printer must be attached...*/
printf("The formfeed, printer ---> f fTestn");
printf("The newline ---> n nn");
printf("The carriage return ---> r rTestingrn");
printf("The horizontal tab ---> t tTestingtn");
printf("The vertical tab ---> v Testingvn");
printf("The backslash ---> Testingn");
printf("The single quote ---> ' 'Testing'''n");
printf("The double quote ---> " "Testing""n");
printf("Some might not work isn't it?n");
return 0;
}
Output example:
Testing the escape sequences:
-----------------------------
The audible bell ---> a
The backspace ---> b___Testing
The formfeed, printer ---> f ?Test
The newline ---> n
Testingriage return ---> r
The horizontal tab ---> t Testing
The vertical tab ---> v Testing?
The backslash ---> Testing
The single quote ---> ' 'Testing' ' '
The double quote ---> " "Testing""
Some might not work isn't it?
Press any key to continue . . .
12/11/2015Session-1/Dr.M.karthika 23
Format specifiers
%d is the format specifier. This informs to the compiler that the incoming value is an integer value.
Other data types can be specified as follows:
%c – character
%f – float
%lf – double
%s – character array (string)
Printf and scanf are defined under the header file stdio.h