2. Contents:
What is c language
History of c language
Features of C Language
Describe the C Program
Input output function:
Variables in C
Data types in C language
Tokens in C
Keywords in C Language
C Identifiers
C Format Specifier
Operators in C language
First Program of C Language
3. C is mother language of all programming language.
It is a popular computer programming language.
It is procedure-oriented programming language.
It is also called mid level programming language.
4. C programming language was developed in 1972 by
Dennis Ritchie at bell laboratories of AT&T(American
Telephone & Telegraph), located in U.S.A.
Dennis Ritchie is known as founder of c language.
It was developed to be used in UNIX Operating system.
It inherits many features of previous languages such as B
and BPCL.
5. There are many features of c language are given below.
1) Machine Independent or Portable
2) Mid-level programming language
3) structured programming language
4) Rich Library
5) Memory Management
6) Fast Speed
7) Pointers
8) Recursion
9) Extensible
6. A variable is a name of the memory location. It is used to store
data. Its value can be changed, and it can be reused many times.
It is a way to represent memory location through symbol so that
it can be easily identified.
type variable_list;
int a;
float b;
char c;
7. A variable can have alphabets, digits,
and underscore.
A variable name can start with the
alphabet, and underscore only. It can't
start with a digit.
No whitespace is allowed within the
variable name.
A variable name must not be any
reserved word or keyword, e.g. int,
float, etc.
Valid variable names:
int a;
int _ab;
int a30;
Invalid variable
names:
int 2;
int a b;
int long;
8. There are many types of variables in c:
local variable
global variable
static variable
automatic variable
external variable
9. There are four types of data types in C language.
Types Data Types
Basic Data Type int, char, float, double
Derived Data Type array, pointer, structure, union
Enumeration Data Type enum
Void Data Type void
10. Tokens in C is the most important element to be used in creating a
program in C.
We can define the token as the smallest individual element in C.
Classification of tokens in C
Tokens in C language can be divided into the following categories:
11. A keyword is a reserved word. You cannot use it as a
variable name, constant name etc.
There are 32 keywords in C language as given below:
auto break case char const continue default do
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatil
e
while
12. C identifiers represent the name in the C program, for example,
variables, functions, arrays, structures, unions, labels, etc.
An identifier can be composed of letters such as uppercase,
lowercase letters, underscore, digits, but the starting letter should
be either an alphabet or an underscore.
Types of identifiers
Internal identifier
External identifier
13. Example of valid identifiers
total, sum, average, _m _, sum_1, etc.
Example of invalid identifiers
2sum (starts with a numerical digit)
int (reserved word)
char (reserved word)
m+n (special character, i.e., '+')
14. Comments in C language are used to provide information
about lines of code. It is widely used for documenting code.
There are 2 types of comments in the C language.
Single Line Comments
Multi-Line Comments
Single Line Comments
#include<stdio.h>
int main(){
//printing information
printf("Hello C");
return 0;
}
Output:
Hello C
Mult Line Comments
#include<stdio.h>
int main(){
/*printing information
Multi-Line Comment*/
printf("Hello C");
return 0;
}
Output:
Hello C
15. The Format specifier is a string used in the formatted input
and output functions.
The format string determines the format of the input and
output.
The format string always starts with a '%' character.
16.
17. An escape sequence in C
language is a sequence of
characters that doesn't represent
itself when used inside string
literal or character.
It is composed of two or more
characters starting with backslash
. For example: n represents new
line.
List of Escape Sequences in C
Escape Sequence Meaning
a Alarm or Beep
b Backspace
f Form Feed
n New Line
r Carriage Return
t Tab (Horizontal)
v Vertical Tab
Backslash
' Single Quote
" Double Quote
? Question Mark
nnn octal number
xhh hexadecimal number
0 Null
18. A constant is a value or variable that can't be changed in the
program, for example: 10, 20, 'a', 3.4, "c programming" etc.
List of Constants in C
Constant Example
Decimal Constant 10, 20, 450 etc.
Real or Floating-point Constant 10.3, 20.2, 450.6 etc.
Octal Constant 021, 033, 046 etc.
Hexadecimal Constant 0x2a, 0x7b, 0xaa etc.
Character Constant 'a', 'b', 'x' etc.
String Constant "c", "c program", etc.
19. There are following types of operators to perform different
types of operations in C language.
1) Arithmetic Operators
2) Relational Operators
3) Special Operators
4) Logical Operators
5) Bitwise Operators
6) Ternary or Conditional Operators
7) Assignment Operator
8) Increment and Decrement Operator
20. Operator Name Description Example
+ Addition Adds together two values x + y
- Subtraction Subtracts one value from
another
x - y
* Multiplication Multiplies two values x * y
/ Division Divides one value by
another
x / y
% Modulus Returns the division
remainder
x % y
++ Increment Increases the value of a
variable by 1
++x
-- Decrement Decreases the value of a
variable by 1
--x
21. Operator Name Description Example
&& Logica
l and
Returns true if both
statements are
true
x < 5 && x
< 10
|| Logica
l or
Returns true if one
of the statements
is true
x < 5 || x <
4
! Logica
l not
Reverse the result,
returns false if the
result is true
!(x < 5 && x
< 10)
22. Assignment operators are used to assign values to variables.
Operator Example Same As
= x = 5 x = 5
+= x += 3 x = x + 3
-= x -= 3 x = x - 3
*= x *= 3 x = x * 3
/= x /= 3 x = x / 3
%= x %= 3 x = x % 3
&= x &= 3 x = x & 3
|= x |= 3 x = x | 3
^= x ^= 3 x = x ^ 3
>>= x >>= 3 x = x >> 3
<<= x <<= 3 x = x << 3
23. Relational Operators are the operators used to create a relationship and
compare the values of two operands.
Types of Relational Operators
Equal To Operator (==)
Not Equal To Operator (!=)
Less than Operator (<)
Greater than Operator (>)
Less than Equal To Operator (<=)
Greater than Equal To Operator (>=)
24. Operators are the predefined symbols of the C/C++ library, and it is used to
perform logical as well as mathematical operations to the operands.
Pre-increment Operator
Post increment Operator
Pre Decrement Operator
Post decrement Operator
Ternary or Conditional Operators
The conditional statements are the decision-making statements which
depends upon the output of the expression.
It is represented by two symbols, i.e., '?' and ':’.
Syntax of a conditional operator
Expression1? expression2: expression3;
25. The bitwise operators are the operators used to perform the operations on
the data at the bit-level.
Operator Meaning of operator
& Bitwise AND operator
| Bitwise OR operator
^ Bitwise exclusive OR operator
~ One's complement operator
(unary operator)
<< Left shift operator
>> Right shift operator
27. #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.
28. There are two input output function of c language.
1) First is printf()
2) Second is scanf()
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.
scanf() Function: is used for input. It reads the input data
from console.
scanf(“format string”,argument_list);