C is a general-purpose programming language developed in the 1970s at Bell Labs. It was designed and written by Dennis Ritchie as a replacement for B programming language. C is a procedural language but features object-oriented programming. Major parts of popular operating systems like Windows and Linux are written in C. It is also commonly used to program devices like microwaves, washing machines, and digital cameras. Key aspects of C include variables, constants, keywords, data types, operators, and control flow statements.
1 of 52
Download to read offline
More Related Content
Introduction to c
2. C is Programming Language
Developed at AT & Ts Bell Laboratory in 1972
Designed and Written by Dennis Ritchie
Replaced more familiar language like PL/I,
ALGOL etc.
Reliable, Simple and easy to use.
3. Nobody can learn directly C++/ Java directly
C++, C# or JAVA make use of object oriented
programming to organize program
Major parts of popular OS like windows, Linux
are still written in C
Common consumer devices like microwave
ovens, washing machines and digital cameras
program part is written in C
Some of 3D computer games
6. VARIABLES
Variables is entity that may change
Variable is nothing but the name given to the
memory cell
CONSTANTS
Constant is an entity that doesnt change
7. KEYWORDS
Reserved Words
Keywords are the words whose meaning has
already been explained to the C Compiler
Keywords cannot be used as variable names.
32 Keyword available in C.
9. Constant can be declared in the way we declare
variable
But during declaration value need to be
assigned to declared contant name. Its value
cannot be modifeid in the program
In another way, Constant is nothing but the
value that we assign to variable.
11. An integer constant must have atleast one digit
It must not have decimal point
It can be either positive or negative
If no sign precedes an integer constant, it is assumed
to be positive
No commas or blanks are allowed within an integer
constant
The allowable range for integer constant is -32768
to 32767 (assuming 16bit Compiler)
12. An integer constant must have atleast one digit
It must have decimal point
It can be either positive or negative
Default sign is positive.
No commas or blanks are allowed within an
integer constant
13. The mantissa part and exponent part should be
separated by a letter e or E
The mantissa part can be positive or negative
Default sign for mantissa is positive
The exponent part must have atleast one digit
which must be a positive or negative integer.
Default sign is positive
14. Any single alphabet, single digit or a single
special symbol enclosed within single inverted
commas.
Both inverted commas should point to left
15. Variable name is any combination of 1 to 31
alphabets, digits or underscores.
The first character in the variable name must be
an alphabet or underscore
No commas or blanks are allowed within
variable name
No special symbol other than an underscore
16. C compiler expects from user to specify type of
variable user want to use in program
This declaration is done at the beginning of
program
Eg. int a, float akc, char code
17. Different types of data allowed to be used in C
language
Primary data types are
o Integer
o Float
o Character
Some modifiers are allowed in C which gives
multiple sub class of data types
Such modifiers are like long, short, signed,
unsigned, double, long double etc..
18. Character occupies 1 byte memory location
Example for character variable declaration
Signed character (Range is -128 to 127)
Unsigned character (Range is 0 to 255)
Format specifier is %c.
19. For 16 bit compiler
2^16=65536
So Range is -32768 to +32767
For 32 bit compiler
2^32=4294967296
So range is -2147483648 to 2147483648
20. Integer
Long
Short
Unsigned
Signed
For 16 bit compiler
Int a; (2byte)
a= 32800
Will not work as it is above 32767
21. long int a; (4byte)
a= 32800
Will work as it is falls in the range of -2147483648
to 2147483648
23. Float occupies 4bytes in memory
-3.4e38 to +3.4e38 (6 digits after decimal point)
Double occupies 8bytes in memory
-1.7e308 to +1.7e308 (12 digits after decimal point)
Long double occupies 10bytes in memory
-1.7e4932 to +1.7e4932 (19 digits after decimal
point)
24. DATA TYPE SIZE RANGE FORMAT
SPECIFIER
int 4byte -2147483648 to 2147483647 %d
unsigned int 4byte 0 to 4294967296 %u
long int/long 4byte -2147483648 to 2147483647 %ld
unsigned long int 4byte 0 to 4294967296 %lu
long long int 8byte -9223372036854775808 To
-9223372036854775807
%lld
short int/short 2byte -32768 to 32767 %hd
unsigned short int 2 byte 0 to 65535 %hu
float 4byte -3.4e38 to 3.4e38 %f
double 8byte -1.7e308 to 1.7e308 %lf
long double 12 byte -1.7e4932 to 1.7e4932 %Lf
char 1byte -128 to 127 %c
unsigned char 1byte 0 to 255 %c
26. Auto Increment/ Decrement Operators
These operators are ++, --,
The operator ++ adds 1
The operator subtracts 1
Two types: Prefix and Postfix auto
increment/decrement
Prefix a=5 b=5
b=++a
After Execution a=6 b=6
29. ==
Checks if values of two operands are equal or not.
If yes then condition becomes true
!=
Checks if values of two operands are equal or not.
If no then condition becomes true
>
Checks value of left operand is more than right
operand. If yes then condition is true
30. <
Checks whether right operand is more than left
operand. If yes then condition is true.
>=
<=
31. AND &&
OR ||
NOT !
AND and OR operators allow two or more
conditions to be combined in if statement.
Not operator reverses the result of an
expression it operates on. The output is logical
value i.e. 0 or 1.
32. AND &
OR |
1s complement operator ~
XOR operator ^
Left shift operator <<
Right shift operator >>
33. Also called as Ternary Operator (?:)
Max=a>b?a:b
34. One Expression may contain different
operators
Precedence means the order in which the
operations are carried out for given
expression.
Associativity comes into picture when
operators of same priority comes into
expression.
35. Hierarchy of Operators
! Logical Not
* / %
Arithmetic and
modulus
+ - Arithmetic
< > <=
>= Relational
== != Relational
&& Logical AND
|| Logical OR
= Assignment
36. printf(Text to printed on output screen);
e.g. printf(WELCOME to DKTE);
printf(Text with format specifier, variable list);
e.g. printf(year is %d, y);
printf(Text with format specifier, expression);
e.g. printf(addition is %d, a+4);
51. Array is a collective name given to group of
memory location containing similar data types.
Array is a collection of similar elements.
Similar elements could be all int, or all float or
all char, etc.
Array of character is called as string.