Basic Syntax of C

In this Tutorial, We learn about Basic Syntax of C Which are Token, semicolon, identifies, keywords.

Let's start with Token so,

💥What is Token in c?A c program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.

💥Why we use Semicolon? 1)In a ‘c’ program, the semicolon is a statement terminator. 2)Each and every statement ends with a semicolon. 3)To write semicolon at the end of a statement to the end of one logical thing. 💥Example: printf(“Hello World”);

💥What is the identifier? Definition:- A name used to identify a variable, a function, or any other user-defined item.

Identifiers are used as the general terminology for the naming of variables, functions, and arrays. These are user-defined names consisting of an arbitrarily long sequence of letters and digits with either a letter or the underscore(_) as a first character. Identifier names must differ in spelling and case from any keywords. You cannot use keywords as identifiers; they are reserved for special use. Once declared, you can use the identifier in later program statements to refer to the associated value. A special kind of identifier, called a statement label, can be used in goto statements.

There are certain rules that should be followed while naming c identifiers:
  • They must begin with a letter or underscore(_).
  • They must consist of only letters, digits, or underscore. No other special character is allowed.
  • It should not be a keyword.
  • It must not contain white space.
  • It should be up to 31 characters long as only the first 31 characters are significant.

Example:-
Valid Identifiers: xyz , abc , xyz_pqr , _xyz,xyz123
Invalid Identifiers: 123, 100xyz, $current



💥What is Keyword?
 Keywords can not be used as constant or variable or as any other identifier names. All         Keywords have fixed meaning and these meanings cannot be changed.


Comment below if you have any queries related to the above tutorial for Basic Syntax of programming language.



Post a Comment

0 Comments