Oct 25, 2019

Basic Sytax of C program

Basic Syntax of C program



basic grammar

We have already seen the basic structure of the C program, which will help us understand the other basic building blocks of the C language.


Basic syntax of c program
Basic syntax of c program


C tokens (Tokens)

C program consists of various tokens, which can be keywords, identifiers, constants, string values, or a symbol. For example, the following C statement includes five tokens:


printf("Hello world");

The five tokens are:

printf
(
"Hello world"
)
;

Semicolon ;

In a C program, the semicolon is the statement terminator. That is, each statement must end with a semicolon. It indicates the end of a logical entity.
For example, here are two different statements:

printf("Hello world!/n");
return 0;

Comment

Comments are like help text in C programs, they are ignored by the compiler. They start with /* and terminate with the characters */ as follows:

/*  This is my first c program */

You cannot nest comments within a comment, nor can a comment appear in a string or character value.

Identifier

The C identifier is the name used to identify a variable, function, or any other user-defined item. An identifier begins with the letters AZ or az or underscore _ followed by zero or more letters, underscores, and numbers (0-9).

Punctuation characters such as @, $, and % are not allowed in C identifiers. C is a case-sensitive programming language. Therefore, in C, Punchi and punchi are two different identifiers. Here are a few valid identifiers:
name, surname, sur_name, sur_123 etc

Keyword

The following table lists the reserved words in C. These reserved words cannot be used as constant names, variable names, or other identifier names.

auto 
break   
case    
char   
const    
continue     
default     
do   
double    
else    
enum   
extern   
float   
for   
goto  
if  
int        
long     
register   
return   
sizeof     
static    
struct  
switch  
typedef    
union  
unsigned   
void  
voilatile     
while   
packed




Disqus Comments