1 - First Chapter History
1 - First Chapter History
1. Alphabets
2. Digits
3. Special Symbols
Alphabets
C language supports all the alphabets from the English language. Lower and upper
case letters together support 52 alphabets.
Lower case letters - a to z
UPPER CASE LETTERS - A to Z
Digits
Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special Symbols
C language supports a rich set of special symbols that include symbols to perform
mathematical operations, to check conditions, white spaces, backspaces, and
other special symbols.
1. Keywords
2. Identifiers
3. Constants
4. Strings
5. Special Symbols
6. Operators
Constants: Constants are also like normal variables. But, the only difference is,
their values cannot be modified by the program once they are defined. Constants
refer to fixed values. They are also called literals. Constants may belong to any of
the data type
Types of Constants:
Data type is used for decide which kind of information we want to use in program
means using data type we can specify which type of data want to use in program.
1) Built In Data Type: Built in data type means those data type already present in
c language called as built in data types.
a) Integer
b) Float
c) Character.
2) User Defined Data Type: those data type create by the user for its own
purpose called as defined data type and it is combination of different type of
data.
a) Structure
b) Union
c) Enum
3) Derived Data Type: Derived data type means those data type can define with
other data type means derived data type can always use with other data type.
a) pointer
b) Function
c) Array
Variables are the some identifier which is used for store the information in
memory means a variable is block of memory and its size is depend on its data
type and which is used for store the data as per its type and variable can modify
or change the value in future.
e.g int a;
As per the above statement here we declare the variable a means we have the
block in memory of 2 byte and its name is a and we can store the integer values in
it.
If we want to work with a variable or declare the variable we have the some
important rules of variable declaration
2) Variable name cannot start with digit but digit may be come later.
3) Cannot use the any special symbol in variable name except underscore
character.
1) Arithmetic Operator
2) Assignment Operator
3) Relational Operator
4) Logical Operator
5) Conditional Operator
7) Bitwise Operator
The bitwise operators are the operators used to perform the operations on the
data at the bit-level. When we perform the bitwise operations, then it is also
known as bit-level programming. It consists of two digits, either 0 or 1. It is mainly
used in numerical computations to make the calculations faster.
| Bitwise OR operator
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 1
Q. what is the constant and why use it as well as explain the types of constant in
c language
Constant means once we initialize the value cannot change later the major goal
of constant is reuse the values
1) integer constant: integer constant cannot store the point values in it e.g 100
2) float constant: float constant can store the decimal point values in it e.g 1.5
3) Character constant: this is used for store the character constant in c language
‘A’,’B’ etc
4) Octal Constant: octal constant start with 0 in c language and range of octal
constant is 0 to 7 e.g. 072 is octal constant
5) Hexa Decimal Constant: Hexa Decimal constant start with 0x and 0X and
between 0 to 15 value.
Conditional operator is used for check the condition and it contains the ternary
operator ? And : operator
Exp1 is always condition and exp2 and exp3 are the options if exp1 is true then
exp2 get executed and if exp1 is false then exp3 executed.
Integer Data Type is used for store the non decimal point values
1) Integer : if we want to use the integer we have the int keyword and memory
size of integer is 2 byte or 4 byte is depend on compiler range is
15 31
2) long integer : long integer is also subtype of integer and it is used for store the
decimal values memory size of long integer is 4 or 8 byte is depend on compiler
and range is
31 63
2 or 2
3) Short integer: short integer is also subtype of integer and it is used for store
the decimal point values and memory size is 2 byte and range
15
4) Unsigned integer: unsigned integer is used for store the positive values
memory size is 2 byte format specifier is %u and range is
16
Character data type is used for store the alpha numeric values means using
character data type we can store the alphabetical values as well some time we
have the alpha numeric values e.g suppose we have the college PRN number it is
combination of character and alphabet TCHJAVA00122.
1) Sign character: if we want to use the sign character we have to use the char in
program and memory size of character data type is 1 byte and the range is -128 to
127
The full form of ASCII is the American Standard Code for information
interchange. It is a character encoding scheme used for electronics
communication. Each character or a special character is represented by some
ASCII code, and each ASCII code occupies 7 bits in memory.
A to Z = 65 to 90
a to z = 97 to 122
0 = 48 to 9 = 57
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.
Format Description
specifier
%d or %i It is used to print the signed integer value where signed integer means
that the variable can hold both positive and negative values.
%u It is used to print the unsigned integer value where the unsigned integer
means that the variable can hold only positive value.
%o It is used to print the octal unsigned integer where octal integer value
always starts with a 0 value.
%g It is used to print the decimal floating-point values, and it uses the fixed
precision, i.e., the value after the decimal in input would be exactly the
same as the value in the output.
2. Multi-Line Comments
#include<stdio.h>
int main(){
//printing information
printf("Hello C");
return 0;
}
Multiline Comments
Multi-Line comments are represented by slash asterisk \* ... *\. It can occupy
many lines of code, but it can't be nested. Syntax:
/*
code
to be commented
*/
#include<stdio.h>
int main(){
/*printing information
Multi-Line Comment*/
printf("Hello C");
return 0;
Compiler:
It is a translator which takes input i.e., High-Level Language, and produces an
output of low-level language i.e. machine or assembly language.
• But its program run time is more and occupies a larger part of memory. It
has slow speed because a compiler goes through the entire program and
then translates the entire program into machine codes.
Interpreter:
An interpreter is a program that translates a programming language into a
comprehensible language. –
void main()
void main()
int c = - -2;
printf("c=%d", c);
void main()
{ int c = - -2;
printf("c=%d", c);
#include <stdio.h>
int main()
{ int i = 3;
int l = i / -2;
int k = i % -2;
return 0;
#include <stdio.h>
int main()
{
int i = 5;
i = i / 3;
printf("%d\n", i);
return 0;
}
#include <stdio.h>
int main()
{ int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
{ int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
int main()
int i = -5;
i = i / 3;
printf("%d", i);
return 0;
#include <stdio.h>
void main()
int a = 5, b = -7, c = 0, d;
printf("\n%d%d%d%d", a, b, c, d);
#include <stdio.h>
void main()
int a = -5;
printf("%d\n", k);
#include <stdio.h>
int main()
int x = 2;
x = x << 1;
printf("%d\n", x);
#include <stdio.h>
int main()
int x = -2;
x = x >> 1;
printf("%d\n", x);
#include <stdio.h>
int main() {
if (~0 == 1)
printf("yes\n");
else
printf("no\n");
#include <stdio.h>
int main()
int y = 0;
if (1 |(y = 1))
else
printf("%d\n", y);
#include <stdio.h>
int main()
int y = 1;
if (y & (y = 2))
else
#include<stdio.h>
int main()
printf("%d\n", res);
return 0;
#include<stdio.h>
int main()
return 0;
#include<stdio.h>
int main()
{ printf("%x\n", -1>>1);
return 0;
#include<stdio.h>
int main()
printf("%x\n", ~m);
return 0;
#include<stdio.h>
int main()
{ printf("%x\n", -1<<3);
return 0;
#include<stdio.h>
int main()
return 0;
#include<stdio.h>
int main()
k=i|j;
l=i&j;
m=k^l;
return 0;
#include<stdio.h>
int main()
return 0;