Month: July 2014

VARIABLES AND EXPRESSIONS

Posted on

USEFULL FOR TYBSC (IT) & TYBSC (CS) STUDENTS

VARIABLES AND EXPRESSIONS:

  • A variable is an identifier that denotes a storage location in memory. It stores numeric

or string values that might change during the program execution.

  • A  variable may  take  different  values  at  different  times  during  the  execution  of  a program but the name of the variable always remains same.
  • A variable is one of the language elements in C# language expressions. An expression is a collection of different language elements that are used to perform a specific task, for example calculation of number.
  • To use expressions, C# provides a complete set of language elements, which are given

as follows:-

i)  Identifiers

ii)  Keywords

iii) Variables

iv) Constants

v)  Data types

vi) Operators 

i)  Identifiers

  •  In  C#,  an  identifier  is  a  name  given  to  a  variable,  constant  or  any  user-defined programming element.
  •  Rules for naming an identifier- An identifier starts with a letter or an underscore and ends with a character.
  •  Identifier are case sensitive-firstname, FirstName, FIRSTNAME are different.
  •  An identifier can have letters, digits and underscores.
  •  An identifier must not be a reserved word.
  •  An identifier must be a complete word without any blank spaces.

ii)  Keywords

  •  Keywords are the reserved words whose meanings are predefined to the C# compiler used for a specific task.
  •  Keywords cannot  use  as  variable,  methods  and  properties  because  they  are  already defined to the compiler to perform specific functionalities.
  •  For example:-class, public, throw, for, while.

iii) Variables

  • Variable  has  a  data  type  that  determines  the  type  of  values that  can  be  stored  in  a variable.
  •  For example : int i;//declaration  i=20;//initialization
  •  A variable can be declared as local or class variable
    • Local variables exist within the scope of a given method in a class
    • Class variables exist for the entire life time of the object instance of a class.
  • Class variables can be used in any method of a class and can be public, private or protected.

iv) Constants

  • Constant is used to store a value  The value of constant does not change during the execution of a program and if tried to assign another value to a constant and compiled then it will display error showing that the left hand side assignment must be a variable, property, or indexer.
  •  A variable is declared as constant using the const keyword.
  •  For example :const int PI=3.14

v)  Data types

  •  C#  supports a  rich  and  varied  selection  of  data  types,  from  built-in  types,  such  as integers or strings, to user-defined types, such as enumerations, structures and classes.
  • C# language provides a rich set of built-in data types
  •  All  variables  whether  user-defined  or  intrinsic(built-in),can  be  used  as  objects anywhere in a program
  • All variables in a program are automatically initialized to default values by the system when they are declared

vi) Operators

  • It is a symbol that takes one or more operands (variables, expressions or values) and operates on them to give an output.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Advertisements

LOCKS

Posted on

USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS

What is Lock?

  • Transaction processing systems usually allow multiple transactions to run concurrently. By allowing multiple transactions to run concurrently will improve the performance of the system in terms of increased throughout or improved response time, but this allows causes several complications with consistency of the data.
  • Ensuring consistency in spite of concurrent execution of transaction require extra work, which is performed by the concurrency controller system of DBMS.
  • A lock is a variable associated with a data item that describes the status of the item withrespect to possible operations that can be applied to it. Generally, there is one lock for each dataitem in the database. Locks are used as a means of synchronizing the access by concurrenttransactions to the database item.

Types of Locks

  • Several types of locks are used in concurrency control. To introduce locking concepts gradually, we first discuss binary locks, which are simple but restrictive and so are not used in practice. Shared/exclusive locks, which provide more general locking capabilities and are used in practical database locking schemes.
  • Depending on the lock mode, when one user has a lock on a record, the lock prevents other users from changing or even reading that record.
  • There are three lock modes: –
  •   SHARED

Row-level shared locks allow multiple users to read data, but do not allow any users to change that data. Table-level shared locks allow multiple users to perform read and write operations on the table, but do not allow any users to perform DDL operations. Multiple users can hold shared locks simultaneously.

  •   EXCLUSIVE

An exclusive lock allows only one user/connection to update a particular piece of data (insert, update, and delete). When one user has an exclusive lock on a row or table, no other lock of any type may be placed on it.

  •   UPDATE

Update locks are always row-level locks. When a user accesses a row with the SELECT… FOR UPDATE statement, the row is locked with an update mode lock. This means that no other user can read or update the row and ensures the current user can later update the row. Update locks are similar to exclusive locks. The main difference between the two is that you can acquire an update lock when another user already has a shared lock on the same record. This lets the holder of the update lock read data without excluding other users. However, once the holder of the update lock changes the data, the update lock is converted into an exclusive lock. Also, update locks are asymmetric with respect to shared locks. You can acquire an update lock on a record that already has a shared lock, but you cannot acquire a shared lock on a record that already has an update lock. Because an update lock prevents subsequent read locks, it is easier to convert the update lock to an exclusive lock.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

OOP in C++

Posted on

OVERLOADABLE/NON-OVERLOADABLEOPERATORS

  • Following is the list of operators which can be overloaded:

1

  • Following is the list of operators, which cannot be overloaded:

::

.*

.

?:

 

  • C# allows user-defined types to overload operators by defining static member functions using the operator keyword. Not all operators can be overloaded, however, and others have restrictions, as listed in this table:

Operators

Overloadability

+, , !, ~, ++, , true, false

These unary operators can be overloaded.

+, , *, /, %, &, |, ^, <<, >>

These binary operators can be overloaded.

==, !=, <, >, <=, >=

The comparison operators can be overloaded (but see the note that follows this table).

&&, ||

The conditional logical operators cannot be overloaded, but they are evaluated using & and |, which can be overloaded.

[]

The array indexing operator cannot be overloaded, but you can define indexers.

(T)x

The cast operator cannot be overloaded, but you can define new conversion operators (see explicit and implicit).

+=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=

Assignment operators cannot be overloaded, but +=, for example, is evaluated using +, which can be overloaded.

=, ., ?:, ??, ->, =>, f(x), as, checked, unchecked, default, delegate, is, new, sizeof, typeof

These operators cannot be overloaded.

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MANAGED CODE and UNMANAGED CODE

Posted on

USEFULL FOR TYBSC (IT) & TYBSC (CS) STUDENTS

MANAGED CODE

  • The  code  that  is  executed  by  the  CLR  environment  rather  than  executed  by  the operating system is called as managed code.
  • The applications that are created using managed code automatically have CLR services, such  as  type  checking,  security,  and  automatic  garbage  collection  these  CLR compiles the applications to MSIL and not the machine code.
  • This  MSIL  along  with  the  metadata  that  attributes,  classes,  and  methods  of  the  code reside in an assembly.
  • The compilation takes place in the managed execution environment, which assures the working of the code.
  • The  benefits  provided  by  the  CLR  can  be  used  by  selecting  one  or  more  language compilers, such as visual basic, C#, visual C++, or any of the third party compilers, such as COBOL, PERL, or Eiffel.
  • The language compiler determines the syntax the must be Used by the code. When the code is complied into managed code, the compiler converts the source code into MSIL, which is central processing unit (CPU) – independent.
  • At this time, the required metadata is generated. The metadata contains the definition of types, member signature, the members in the code, and other details that the code uses at the time of execution. Next, MSIL must be converted into CPU – specific code by the JIT compiler, before the execution of the code.  The role of JIT compiler is to translate the MSIL into native code.
  • The  runtime  also  supports  another  method  of  compilation  named  install – time  code generation.  It converts MSIL into native code in a single shot by taking a larger unit of code at a time.
  • The  entire  assembly  is  converted  into  native  code  at  the  installation  time  itself.  By default, it takes care of other assemblies’ referred in this assembly. It stores the resulting native code for use when the assembly is loaded and run. Using the install – time code generation, the entire assembly that results in loading the code files more rapidly.

1

Posted By-:Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

Atomicity Consistency Isolation Durability (ACID)

Posted on

USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS

Atomicity Consistency Isolation Durability (ACID)

Qu.1 – What does Atomicity Consistency Isolation Durability (ACID) mean?

Atomicity Consistency Isolation Durability (ACID) is a concept referring to a database system’s four transaction properties: atomicity, consistency, isolation and durability.

Qu.2 – Explain Atomicity Consistency Isolation Durability (ACID).

A database guarantees the following four properties to ensure database reliability, as follows:

Atomicity: A database follows the all or nothing rule, i.e., the database considers all transaction operations as one whole unit or atom. Thus, when a database processes a transaction, it is either fully completed or not executed at all.

Consistency: Ensures that only valid data following all rules and constraints is written in the database. When a transaction results in invalid data, the database reverts to its previous state, which abides by all customary rules and constraints.

Isolation: Ensures that transactions are securely and independently processed at the same time without interference, but it does not ensure the order of transactions. For example, user A withdraws $100 and user B withdraws $250 from user Z’s account, which has a balance of $1000. Since both A and B draw from Z’s account, one of the users is required to wait until the other user transaction is completed, avoiding inconsistent data. If B is required to wait, then B must wait until A’s transaction is completed, and Z’s account balance changes to $900. Now, B can withdraw $250 from this $900 balance.

Durability: In the above example, user B may withdraw $100 only after user A’s transaction is completed and is updated in the database. If the system fails before A’s transaction is logged in the database, A cannot withdraw any money, and Z’s account returns to its previous consistent state.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

OOP in C++

Posted on Updated on

For the students of FYBSc (IT), SYBSc (CS), SYBCA

OPERATOR OVERLOADING

  • C++ allows specifying more than one definition for an operator in the same scope, which is called operator overloading respectively.
  • When to call an overloaded operator, the compiler determines the most appropriate definition to use by comparing the argument types used to call the function or operator with the parameter types specified in the definitions. The process of selecting the most appropriate overloaded operator is called overload resolution.
  • Overload most of the built-in operators available in C++ and thus a programmer can use operators with user-defined types as well.
  • Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined. Like any other function, an overloaded operator has a return type and a parameter list.

Boxoperator+ (constBox&);

  • The above code declares the addition operator that can be used to add two Box objects and returns final Box object. Most overloaded operators may be defined as ordinary non-member functions or as class member functions. In case we define above function as non-member function of a class then we would have to pass two arguments for each operand as follows:

Boxoperator+ (constBox&,constBox&);

  • Following is the example to show the concept of operator over loading using a member function. Here an object is passed as an argument whose properties will be accessed using this object, the object which will call this operator can be accessed using this operator as explained below:

#include <iostream.h>
#include <conio.h>
class Box
{ public:
double getVolume(void)
{
return length * breadth * height; }
void setLength( double len )
{ length = len; }
void setBreadth( double bre )
{ breadth = bre; }
void setHeight( double hei )
{ height = hei; }

// Overload + operator to add two Box objects.
Box operator+(const Box& b)
{ Box box;
box.length = this->length + b.length;
box.breadth = this->breadth + b.breadth;
box.height = this->height + b.height;
return box; }
private:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box};

void main( )
{
clrscr();
Box Box1; // Declare Box1 of type Box
Box Box2; // Declare Box2 of type Box
Box Box3; // Declare Box3 of type Box
double volume = 0.0; // Store the volume of a box here

// box 1 specification
Box1.setLength(6.0);
Box1.setBreadth(7.0);
Box1.setHeight(5.0);

// box 2 specification
Box2.setLength(12.0);
Box2.setBreadth(13.0);
Box2.setHeight(10.0);

// volume of box 1
volume = Box1.getVolume();
cout << “Volume of Box1 : ” << volume <<endl;

// volume of box 2
volume = Box2.getVolume();
cout << “Volume of Box2 : ” << volume <<endl;
// Add two object as follows:
Box3 = Box1 + Box2;

// volume of box 3
volume = Box3.getVolume();
cout << “Volume of Box3 : ” << volume <<endl;
getch();}

 

When the above code is compiled and executed, it produces the following result:

Volume ofBox1:210

Volume ofBox2:1560

Volume ofBox3:5400

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

SQL

Posted on

SQL LANGUAGE:

 

  1. SQL is a tool for organizing, managing, and retrieving data stored by a computer      database. The acronym SQL is an abbreviation for Structured Query Language. For historical reasons, SQL is usually pronounced “sequel” but the alternate pronunciation “S.Q.L.” is also used.
  2. As the name implies, SQL is a computer language that to use to interact with a database. In fact, SQL works with one specific type of database, called a relational database.
  3. When you need to retrieve data from a database, we use the SQL language to make the request. The DBMS processes the SQL request, retrieves the requested data, and returns it to us.
  4. This process of requesting data from a database and receiving back the results is called a database query- hence the name Structured Query Language.
  5. SQL is thus a comprehensive language for controlling and interacting which a database management system.
  6. Second, SQL is not really a complete computer language like COBOL, C, C+ +, or java. Instead, SQL is a database sublanguage, These SQL statements can be embedded into another language, such as COBOL or C, to extend that language for use in database access.
  7. SQL is used to control all of the functions that a DBMS provides for its users, including:

                i. Data Definition: SQL lets a user define the structure and organization of the stored data and relationships among the stored data items.

               ii. Data retrieval: SQL allows a user or an application program to retrieve stored data form the database and use it.

              iii. Data manipulation: SQL allows a user or an application program to update the database by adding new data, removing old data, and modifying previously stored data.

              iv. Access control: SQL can be used to restrict a user’s ability to retrieve, add, and modify data, protecting stored data against unauthorized access.

              v. Data sharing: SQL is used to coordinate data sharing by concurrent users, ensuring that they do not interfere with one another.

             vi. Data integrity: SQL defines integrity constraints in the database, protecting it from corruption due to inconsistent updates or system failures.

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com