2. Popularity of ‘C’
● Robust
● Efficient and fast
● Portable
● Structured Programming
www.eshikshak.co.in
3. Character Set
● A character can a number, alphabet, or
any special symbol to represent
information
Alphabets A, B, ….., Y, Z
a, b, ……, y, z
Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special symbols ~ ‘ ! @ # % ^ & * ( ) _ - + =
|{}[]:;"'<>,.?/
www.eshikshak.co.in
4. Constants, Variables and
Keywords
● A combination of character set’s
numbers, alphabets and special
symbols forms constants or variable or
keywords
Alphabets, Numbers and Special
Symbols
Constants Variables Keywords
www.eshikshak.co.in
5. Constants
● A value that does not change during the
execution of programming.
Constants
Primary Secondary
Constants Constants
www.eshikshak.co.in
6. Variables
● Variables in C have the same meaning as
variables in algebra. That is, they represent
some unknown, or variable, value.
x=a+b
z + 2 = 3(y - 5)
● Remember that variables in algebra are
represented by a single alphabetic
character.
www.eshikshak.co.in
7. Keywords
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
www.eshikshak.co.in
8. Program Structure in C
● EACH complete C program is composed of:
● Comment statements
● Pre-processor directives
● Declaration statements
● One or more functions
● Executable statements
www.eshikshak.co.in
9. C Syntax and Hello World
#include inserts another file. “.h” files are called
“header” files. They contain stuff needed to interface to
libraries and code in other “.c” files. Can your program have
What do the < > more than one .c file?
mean?
This is a comment. The compiler ignores this.
#include <stdio.h>
The main() function is always
/* The simplest C Program */ where your program starts
int main(int argc, char **argv) running.
{
Blocks of code (“lexical
printf(“Hello Worldn”);
scopes”) are marked by { … }
return 0;
}
Return ‘0’ from this function Print out a message. ‘n’ means “new line”.
www.eshikshak.co.in
10. Comment Statements
● Formal Comments:
/* Comment ….. */
● Used for detailed description of functions or
operations (for our benefit, not compiler’s).
● Can take multiple lines in source file.
www.eshikshak.co.in
11. Pre-Processor Directives
#include -- header files for library functions
Example:
#include <stdio.h>
Note Space
#define -- define constants and macros
Examples:
#define e 2.7182818
#define pi 3.14159265359
Note Spaces
www.eshikshak.co.in
12. Declarations
● Declarations tell the compiler what variable
names will be used and what type of data
each can handle (store).
● Example declarations:
int a, b, c ;
float r, p, q ;
double x, y, z ;
char m, n ;
www.eshikshak.co.in