Header Ads

Breaking News

C tutorials C Syntax

Syntax For C:
Let a look at the basic structure of c programs C program, It is very easy to understand other basic
building blocks of the C programming language.
Tokens of C:
The token is either a keyword, an identifier, a constant, a string or a symbol, a C program has various types of tokens.
The following C statement of Five tokens

printf(“Hello World”);



The characterize token are-

printf
(
“Hello World”
)
;








Semicolons:

In a C program, the semicolon is an aborted statement. That is, each individual statement must be ended with semicolon. It indicates and is a logical entity.
Given bellow two different Structure-
printf(“Hello World”);
return 0;

Comments:

Comments are helping text format in the C program. They are ignoring format for your compiler. Like /*my first program*/. You cannot have comments and they do not occur within a string or character literals.

Identifier:

A C identifiers mainly used to identify the variable function or any at the user-defined item. An identifier starts with a letter A to Z, a to z or an underscore’_’ followed by zero or more letters, underscores, ad digits(0-9).
Also Codes not allow punctuation character like @,$ and % for use as an identifier. C is a case conscious programming language  Thus, Manpower and manpower two various identifiers in C. Hence are some examples of acceptable identifiers.
Mohd
Zara
abc
move_name
A_123
myname50
_temp
j
a23b9
retVal

Keywords:

The following list shows the reserved words in C. These reserved words any not be used constants or variables or either identifier.
Auto
Else
Long
Switch
Break
Enum
Register
Type
Case
Extern
Return
Union
Char
Float
Short
Unsigned
Const
For
Signed
Void
Continue
Goto
Sizef
While
Default
If
Static
Volatile
Do
int
struct
double
_packed

                                                     









Whitespace:
A line holding the only whitespace, possibly with a comment is known as an empty line, and a C compiler totally avoids it.
Describing blanks, tabs, the newline character, and comments in a C by using the whitespace term. Whitespace individuals are part of a statement from another and enables the compiler to identify where are element begins, therefore, in the following statement-
int age;


There must be at least one whitespace character between int and age for the compiler to be able to characterize them. Or the other hand in the following statement-
fruit=apple+orange;

no whitespace  use in above statement, because it is not mandatory between fruit and =, or between = and apple, although you are free to include the same if you wish to increase readability.

No comments