Friday, 22 November 2013

c Basic Syntax

The basic structure of C programming is easy and it will be help full to understand other building blocks of the C programming language.
C Programming
C Programming


Tokens:

A token in c programming is either a keyword, an identifier, a constant, a string literal, or a symbol.
For example,
the following statements of a c program consist  five tokens:
printf("Hey, World! \n");
The five tokens are:
1.printf
2.(
3."Hey, World! \n"
4.)
5.;

Semicolons(;)

The semicolon is a statement terminator in a c program.
Each statement in c must be ended with a semicolon.

For example,the two different statements:
1.printf("Hey, World! \n");
2.return 0;
each statement is ended with a semicolon.

Comments:

Comments helps to easily understand your C program and they are not compile by the compiler.
They start with /* and terminates with the characters */ as shown below:

/* c program for print hello */
You cannot have comments within comments.

Identifiers:

A identifier is a name used to identify a variable, function, or any other user-defined item.
An identifier would be start with a letter A to Z or a to z or an underscore _ followed by zero or more letters, underscores, and digits (0 to 9).
the followimg symbols cannot be used within identifiers .@, $, and % .

Here 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 may not be used as constant or variable or any other identifier names.

auto       else        long       switch
break    enum    register                typedef
case       extern  return   union
char       float       short     unsigned
const     for          signed   void
continue              goto       sizeof    volatile
default if             static     while
do           int           struct    _Packed
double
C - Overview
C - Basic Syntax
C - Data Types
C - Variables
C - Constants
C - Storage Classes
C - Operators
C - Decision Making
C - Loops
C - Functions
C - Scope Rules
C - Arrays
C - Pointers
C - Strings
C - Structures
C - Unions
C - Bit Fields
C - Typedef
C - Input & Output
C - File I/O
C - Preprocessors
C - Header Files
C - Type Casting
C - Error Handling
C - Recursion
C - Variable Arguments
C - Memory Management
C - Command Line Arguments

Related Posts:

  • Scope Rules In C A scope in any program is a that region of the program where a defined variable can have its existence and beyond that variable can't be accessed. The three places where variables can be declared in C programming l… Read More
  • Decision Making Structure In C Decision making structures allows the programmer to specify one or more conditions to be evaluated or tested by the compiler or , along with a statement or set of statements to be executed if the condition is  … Read More
  • Storage Classes in c A storage class in C defines the scope (visibility) and life-time of a variables and/or a functions .These specifiers precede the type that they modify. There are some storage classes, which are  used in a C Pr… Read More
  • C language 'C' is a well known programming language which was developed by Dennis  Ritchie  in 1972 in  AT&T Bell Labs. This programming language was influenced by B , BCPL ,  ALGOL, and some other programming… Read More
  • String In C The string in C programming language is a one-dimensional array of characters which is terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by… Read More

0 comments:

Post a Comment