Structure of C' Program
Structure of C' Program
Program
Constants, Variables and Data-types
A Computer Programming and Utility Project
Created By:
Shubham Thakur
Introduction
Data needs to be processed for manipulation
Character Set
Character grouping in C:
Letters
Digits
A B C Z
0 1 2 3 4 5 6 7 `~!@#$%^_+89
=\/?
a b c z
White spaces:
Blank Space
Horizontal Tab
Carriage Return
New line
Form Feed
Special
Characters
() ][{}|<>:;,.
&*
Tri-graph Characters
Tri-graph Characters: When some symbols are
??(
??)
??<
??>
??!
??/
??\
??-
C Tokens
Keyword
Keyword
s
s
auto
auto
break
break
case
case
const
const
Identifie
Identifie
rs
rs
X999
X999
_S93
_S93
num
num
g_nd45
g_nd45
Constants
Constants
Numeric
Numeric Constants
Constants
Character
Character
Constants
Constants
Integer
Integer
Constan
Constan
ts
ts
Real
Real
Constan
Constan
ts
ts
Single
Single
characte
characte
rr
Constan
Constan
ts
ts
+123
+123
199
199
-033
-033
0XA3
0XA3
0.082
0.082
-9.5
-9.5
+.32
+.32
1.5e+5
1.5e+5
5
5
e
e
X
X
String
String
Constan
Constan
ts
ts
\a
\a
\n
\n
\? \0
\0
\?
\\
\\
Strings
Strings
Special
Special
Symbols
Symbols
Operato
Operato
rs
rs
3Ap
3Ap
ple
ple
Black
Black
99
99
@#
@#
B49
B49
{}:_@
{}:_@
#)
#)
=+=+/!<
/!<
<<
<< >>
>>
Syntax
#include<stdio.h> //special
symbol
(#<>)
<headerfile>
double
answer=0; //keyword
identifier=numeric constant
char
name=apple; //keyword
identifier=string
a=b*c;
//variable(a)
operator(=,*)
constant (b,c)
As given in the next example, the words in
white, such as void, int, float etc. are the
keywords.
Example
Variables
Rules:
Valid variables:
_my_name, Void, doublE, iNT, i99, _98, NaMe,
naMe, Name, etc. are different.
Invalid variables:
int, float, 99i, my name, 9_8, Na me, 99, 10th,
Data
types
ANSI C supports 3 classes of data types:
Declaration of Variables
Primary type declaration:
data-type v1,v2,vn;
Example:
int count;
int number, total;
double ratio;
int and double represents
integer & real type data values.
is copied in
to a in left
Reading
data
from
keyboard
/*Some data has to be sent to the compiler for its computation, such
intake of values can be done by the syntax:*/
int roll; float marks; char grade, name; // local declaration
printf(Enter Roll. No., name, marks out of 50 and grade of the
student:\n);
scanf(%d %s %f %c,&roll,name,&marks,grade);
printf(\nnext comes the data accpted by the compiler:\n);
printf(%d\n%s\t%f\t%c,roll,name,marks,grade);
/*printf function helps user to interact with the compiler, about the
sequence of entering the data, and sequentially it is accepted by the
compiler using the scanf function.*/
/* output:
Enter Roll. No., name, marks and grade of the student:
50 Alex 45.003 A
next comes the data accepted by the compiler:
50
Alex45.003 A
*/
#define PI 3.14
and fixed
#define num 31.4
#define Min 10