Syntax of c program :-
A C program is made of different tokens combined together. These tokens include :-
* Keywords
* identifiers
* Constants
* variable
let's describe all of these :-
* Keyword :- Keywords are reserved words that can not be used elsewhere in the program for naming a variable or function. Instead they have a specific fumction or tasks and they are solely used for that.
Ex-
* Identifiers :- identifiers are names given to variable or functions in the order to diffrentiate them from one another. They are solely based on our choice but there are few rules that we have to follow while naming identifiers.
NOTE :- The name cannot contain special symbols such as , @ , - , * , <> etc.
* Constants :- An entity whose value doesn't change is called a constant .
Types of constant :-
(1) Integer constant - ( 1 ,6 , 4 , 9 )
(2) Real constant - ( -322.1 , 2.5 ,6.0 )
(3) Character contant :- [( 'a' , '$' , '@' ) closed with single inverted commas ]
* Variables :- A variable is a container for stores a 'value' . In the kitchen we have containers for storing Rice , Dal , Sugar etc Similar to that variables in C stores the value of a constant.
Ex:-
a = 3 a is assinged "3"
b = 5.3 b is assinged "5.3"
c = 'A' c is assinged "A"
=> Rules for Naming variable in C :-
1> The first character must be an alphabet or underscore ( _ ).
2> No commas or blanks are allowed .
3> No special symbol other than underscore is alloewed .
4> variable names are case sensitive.
5> Can't start with a digit .
6> No white soace & reserved keywords is allowed .
Valid variable names :-
int a; , int ad; , float ad123; , char N;
In the next article we will discuss about Data types and Operators in C .
If any type of query just comment here
ReplyDelete