CH 01
CH 01
CH 01
Using C
Ex.: +325.34
426.0
-32.76
-48.5792
The part appearing before ‘e’ is called mantissa, whereas the part following ‘e’
is called exponent. Following rules must be observed while constructing real
constants expressed in exponential form:
Ex.: +3.2e-5
4.1e8
-0.2e+3
-3.2e-5
Rules for Constructing Character Constants
(a) A character constant is 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. For example, ’A’ is a valid character constant whereas
‘A’ is not.
(b)The maximum length of a character constant can be 1 character.
Ex.: 'A'
'I'
'5'
'='
Rules for Constructing Variable Names
(a)A variable name is any combination of 1 to 31 alphabets, digits or underscores. Some
compilers allow variable names whose length could be up to 247 characters. Still, it
would besafer to stick to the rule of 31 characters. Do not createunnecessarily long
variable names as it adds to your typing
effort.
(b)The first character in the variable name must be an alphabet or underscore.
(c)No commas or blanks are allowed within a variable name.
(d)No special symbol other than an underscore (as in gross_sal) can be used in a
variable name.
Ex.: si_int
m_hra
pop_e_89
C Keywords
The First C Program
#include <stdio.h> Receiving Input
main( ) #include <stdio.h>
{ main( )
int p, n ; {
float r, si ; int p, n ;
p = 1000 ; float r, si ;
n=3; printf ( "Enter values of p, n, r" ) ;
r = 8.5 ; scanf ( "%d %d %f", &p, &n, &r ) ;
/* formula for simple interest */ si = p * n * r / 100 ;
si = p * n * r / 100 ; printf ( "%f" , si ) ;
printf ( "%f" , si ) ; }
}
C Instructions
Three types of instructions in C:
(a)Type declaration instruction − To declare the type of variables used in a C
program.
(b)Arithmetic instruction − To perform arithmetic operations between
constants and variables.
(c)Control instruction − To control the sequence of execution of various
statements in a C program.