quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Statements

A statement, by definition, includes a terminating semi-colon.

   

space.gif

Example :

   

space.gif

  • integer i;
  • a = bn;
   

space.gif

The following is not legal and generates a parse error.

   

space.gif

if(1) ; else ;

   

space.gif

  ../images/main/bullet_star_pink.gif Example : Statement
   

space.gif


 1 program statement {
 2   // Valid statements
 3   integer a;
 4   a = 10;
 5   // Invalid statements
 6   if (10); else; // This will give compile error
 7 }
You could download file statement.vr here
   

space.gif

  ../images/main/bulllet_4dots_orange.gif Statement Blocks

A statement block, by definition, is created by using braces to group a sequence of variable declarations and statements. The declared variables are visible to the statements declared within the braces.

   

space.gif

{

statment1;

statement2;

}

   

space.gif

Empty block is {} without any statments in it.

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : Statement Block
   

space.gif


  1 program statement_block {
  2   {
  3     integer i = 10;
  4     printf ("Value of i : %d\n",i);
  5   }
  6   // Empty statement block
  7   {
  8 
  9   }
 10   // One more statment block
 11   {
 12     integer j = 15;
 13     printf ("Value of j : %d\n",j);
 14   }
 15 }
You could download file statement_block.vr here
   

space.gif

  ../images/main/bulllet_4dots_orange.gif Assignment

Assignment is the primitive operation to initialize or change the value of a variable. Assignments are allowed in the scope of a program, task, function or statement block.

   

space.gif

Syntax variable_name = expression;

   

space.gif

Is the name of the variable to which the value is assigned. expression The value of the expression evaluated at the execution of the assignment is assigned to the variable.

   

space.gif

Variable declarations must be placed before any executable statements in a program, task, function, or statement block. Optionally, a variable declaration may contain an assignment to initialize the variable. Initializations are equivalent to inserting assignments to variables before the first executable statement.

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Compound Assignment

Vera supports compound assignments that are equivalent to valid assignments in a compacted form.

   

space.gif

Syntax var1 operator= var2 ; operator

   

space.gif

Supported operators are: +, - , *, /, %, & (bit-wise and), | (bit-wise or), ^ (bit-wise exclusive or), << and >>, also &~ |~ ^~, for which the compound operators are named ~&= ~|= ~^=.

   

space.gif

The compound assignment performs the same operation as:

   

space.gif

var1 = var1 operator var2;

   

space.gif

Vera does not support assignment recursion as in C and C++ language.

   

space.gif

  ../images/main/bullet_star_pink.gif Example : Compound Assignment
   

space.gif


 1 program compound_assignment {
 2   integer i = 55; // Variable init
 3   integer j = 20; // one more variable
 4   integer m,n;
 5   i = j + 1; // Compound assignment
 6   i ++ ;// 
 7   // Below code is invalid assignment
 8   m = n = i;
 9 }
You could download file compound_assignment.vr here
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com