Вы находитесь на странице: 1из 20

 C is a general purpose programming

language.
 ‘C’ language is developed at AT & T’s Bell
Laboratories of USA in 1972.
 Designed & written by Dennis Ritchie.
 Flow diagram:

Constants
Variables Instructions Programs
keywords
 Variables & constants are the basic data objects
manipulated in a program.
 A variable can be considered as a name given to
any
memory location. Example : int i;
 Here ‘i’ is a name assigned to a particular
memory location.
 A constant is a quantity that does not change.
 The qualifier const can be applied to the
declaration of any variable to specify that its
value will not be changed.
 Example : const int i = 500;
 Keywords are the words whose meaning has
already been explained to the C Compiler.
 The keyword can not be used as variable
names.
 The keywords are also called “Reserved
Words”.
 There are 32 keywords available in C.
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
Volatile while
 There are basically four types of instructions in C.
1) Type Declaration Instruction : to declare the
type of
variable used in C program.
2) Input / Output Instruction : supplying input
data to a
program and obtaining the output results from
it.
3) Arithmetic Instruction : To perform arithmetic
operations between constants and variables.
4) Control Instruction : to control the sequence
of execution of various statements in C
program.
 There are only a few basic data types in C.
Integer
Float
Double
Character
 Any number in the range -32768 to +32767.
 Occupies 2 bytes in the memory.
 can be declared as : int i;
 sometimes we know in advance that the value
stored in a given integer variable will always
be positive. In such a case we can declare the
variable to be unsigned, as unsigned int i;
 Range will shift to 0 – 65535. Thus it almost
double the size of largest possible value.
 It still occupy 2 bytes only.
 signed integer is nothing but our ordinary int.
signed int i;
 The general range of an integer is from -32768 to
32767.
 If user require a bigger range, it can be achieved
using the
long integer.
 long integer require twice the memory space(4 bytes)
than the ordinary integer.
 It can be declared as : long int i;
 long integer cause the program to run a bit slower,
but the
range is expanded tremendously.
 Range : -2147483648 to 2147483647
 short integer is nothing but our ordinary int.
short int I;
 any real number
 can be expressed in two forms :
Fractional form and exponential form.
 In exponential form, the real constant is
represented in
two parts like 3.4 e 5
the part before ‘e’ is called mantissa,
whereas the part following ‘e’ is called exponent.
 Range of float is -3.4e38 to 3.4e38
 Consumes 4 bytes in memory.
 It can be declared as : float f;
 if the range of float is insufficient then C offers a
double
data type.
 It occupies 8 bytes in memory.
 It has a range from -1.7e308 to +1.7e308.
 It can be declared as,
double a;
 Range beyond the double is offered by long
double
 A long double occupies 10 bytes in memory. It
can be
declared as : long double t;
 It’s range is : -1.7e4932 to +1.7e4932
 It is either a single alphabet, a single digit or a
single
special symbol enclosed within single inverted
commas.
 Both the inverted commas should point to the
left.
 ’A’ is a valid character whereas ‘A’ is not.
 Maximum length of a character is 1 character.
 It occupies 1 byte in memory.
 It can be declared as : char ch;
 character has a range of -128 to 127
 A signed character is same as the ordinary
character.
 It has a range from -128 to 127.
 It can be declared as : signed char ch;
 An unsigned character has a range from 0 to
255.
 It can be declared as : unsigned char ch ;
 Both occupies 1 byte in memory.
 printf() is a function which is used to print the
formatted output on the screen.
 The general form of printf statement is
printf(“<format string>”,<list of variables>);
 Format string is a character string which
contains two types of objects
Plain characters
Conversion specifications
 Plain characters are simply copied to the
output screen.
 Conversion specifications fetch arguments
from the argument list and apply formatting
to them.
 Examples :
printf(“Prolific, Ahmedabad”);
printf(“Value of i is %d “,i);
Data type Range Bytes Format
Signed char -128 to 127 1 %c
Unsigned char 0 to 255 1 %c
Short signed int -32768 to 2 %d
32767
Short unsigned 0 to 65535 2 %u
int
Long signed int -2147483648 4 %ld
to
+2147483647
Long unsigned 0 to 4 %lu
int 4294967295
Float -3.4e38 to 4 %f
+3.4e38
Double -1.7e308 to 8 %lf
+1.7e308
Symbol Specification
\a Alert (bell) character
\b Backspace
\f Form feed
\n New line
\r Carriage return
\t Horizontal tab
\v Vertical tab
\\ Backslash
\? Question mark
\’ Single quote
\” Double quote
Thank You

Вам также может понравиться