Академический Документы
Профессиональный Документы
Культура Документы
b)
A,B,C..X,Y,Z
ab,c.x,y,z
Numbers
0,1,2..9
Special
~,!,@,#,$,%,^,&,*,(,)_,+,=,|,\,},{,],
Characters [,;,,,<,.,?,/.
Keywords of C
Keywords are the words whose meaning has already
been explained to the C compiler. The keywords
cant be used as variables . there are only 32 key
words in c . they are :
Auto break case char const
default
do double
Else
enum extern float
long register
continue
for goto
if
int
Return
short signedsizeof
switch typedef
union
Unsigned void
volatile
static struct
while
asm
near
entry
pascal
far
fortran
Data types
C supports several different types of data
,each of which may be represented differently
with in the computer memory.The basic data
types are listed below .the memory
requirement are also given .
Data type
Description
memory requirements
Char
1 byte
Single character
Int
2 byte
integer quantity
Float
byte
Double
8 byte
double precision
# etc
c=a+b; .. a =4; b
etc.
Rules for constructing variables name:-Variable name must be begun with any alphabets.
-except digits, underscore and alphabets, no other
special character are allowed.
-C key words should not be used as variables name.
-both uppercase and lower case variable are significant
in C.
variables
Numeric
variables
Non numeric
variables
real
integer
Short int
long int
character
string
Float
double
Unsigned
int
Escape sequence
Certain nonprinting characters, as well as the backslash (\) and
apostrophe (), can be expressed in terms of escape sequence. And
escape sequence always begins with a backward slash and is followed
by one or more special characters.
character
\a
bell (alert)
\b
backspace
\t
horizontal tab
\v
vertical tab
\n
new line
quotation mark ()
apostrophe (,)
\?
Question mark
\\
Backslash (\)
I/O function
An input output function can be accessed from any where with in the program simply by writing
the function name, followed by a list of arguments enclosed in parentheses. The arguments
represent data items that are sent to the function. Some input/output function do not require
arguments, through the empty parentheses must still appear.
char c;
.
c=getchar();
The first statement declared that c is a character type variable. The second statement causes a
single character entered from keyboard and assigned to c.
..
Putchar (c);
The first statement declared that c is a character type variable. The second statement causes
the current value of c to be transmitted to the monitor where it will be displayed.
single character
%d
decimal integer
%e
%f
%o
octal value
%s
string
%u
%x
hexadecimal
Eg.
#include<stdio.h>
void main()
{
int a,b;
char c;
float e;
Scanf( %d %d %c %f,&a,&b,&c,&e);
.
..
}
Within the scanf function, the control string are %d %d %c %f. it contains three different groups.
The %d indicates the first two arguments(&a,&b), %c indicates the third argument(&c) and %f
indicates last arguments(&e).
Where control string refers to a certain required formatting information, and arg1,
arg2..are argument refers individual input data items. The control strings means
required formatting string starting with percentage sign (%) are
%c
single character
%d
decimal integer
%e
%f
%o
octal value
%s
string
%u
%x
hexadecimal
Eg. 1
#include<stdio.h>
void main()
{
int a,b;
char c;
float e;
a=20;
b=30;
c=A;
e=3.1416;
printf(%d, %d, %c, %f,a,b,c,e);
.
}
Within the printf function, the control string are %d %d %c %f. it contains three different groups.
The %d indicates the first two arguments(a,b), %c indicates the third argument(c) and %f
indicates last arguments(e).
Eg 2
/* program to calculate simple interest*/
#include<stdio.h>
#include<conio.h>
Void main()
{
Float p,t,r,I;
Clrscr();
Printf(enter the principle);
Scanf(%f,&p);
Printf(enter the time);
Scanf(%f,&t);
Printf(enter the rate);
Scanf(%f,&r);
I=(p*t*r)/100;
p=2*(l+b);
printf(the perimeter is %.2f,p);
getch();
}
Eg.5
/*program to calculate volume*/
#include<stdio.h>
#include<conio.h>
Void main()
{
Float v,l,b,h;
cLrscr();
printf(enter the value of breath);
scanf(%f,&b);
printf(enter the value of length);
scanf(%f,&l);
printf(enter the value of height);
scanf(%f,&h);
v=l*b*h;
printf(the volume is %.2f,v);
getch();
}