C Programming Questions

C Programming Questions

  • Submitted By: prabhat6
  • Date Submitted: 01/06/2014 1:46 AM
  • Category: Technology
  • Words: 1774
  • Page: 8
  • Views: 109


Explain C tokens (2 marks)

Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. A token is source-program text that the compiler does not break down The C compiler recognizes the following kinds of tokens:       keywords : these are reserved identifiers having predefined meanings identifiers : these tokens name functions, variables, constants, and types literals : these tokens that specify values operators : these tokens are used to combine values in expressions punctuation : these tokens separate or terminate complex constructions special : these tokens have special meaning to the preprocessor or compiler

A token can be a reserved word (such as int or while), an identifier (such as b or sum), a constant (such as 3.14 or "Arvind Kumar"), a delimiter (such as { or ;) or an operator (such as + or =). Example: Consider the following program: main() { int r=10, area; area = 3.14 * r * r; printf("area of circle = %d\n", area); } The tokens in this program are: main ( ) { int r = 10 , area ; 3.14 * identifier left bracket, delimiter right bracket, delimiter left brace, delimiter reserved word identifier equals sign, operator constant comma, delimiter identifier semicolon, delimiter constant asterisk, operator

and so on. Thus a C program is a ‘stream of tokens’


 

Explain C Keywords What is a keyword? State two keywords of C

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while

All 32 keywords are in lower case letters. These keywords are reserved and cannot be redefined. Following rules must be kept in mind when using keywords. ...

Similar Essays