Search........

Google

Sunday, March 2, 2008

Before we start....

Variable :-

Variable is a named memory location
For a variable there will be memory address
value
e.g. :- inum,inum1,fnum,cname;



Rules For Declaring Variables :-

A Variable Should Start with an Alphabet
e.g. a, b,a1,name
Key Words are not allowed
e.g. int,float....etc
No special characters are allowed
e.g. @,#,! Etc... Exception is underscore(_)
Numbers are allowed ....
e.g. a12,b034 etc
Number should not be the Starting
e.g. 12a,13a these are wrong decleration



Data Types :-

Data type shows which type of values should a variable hold
There are mainly four types of basic data types
int - integer
float - floatting
double - double type value
char - character type value
e.g : - int a=10;
float c=15.5;
double aa=10.557857;
char ch=‘a’;
here a is a character not a variable so it is in single codes


Operator :-

Operators are used to do perform some operations on the variables

There are three types of operators
Arithmetic Operators
Relational ,,
Logical ,,


Arithmetic Operators :-

Arithmetic Operators are used to do mathematical operations
e.g . c=a+b;

The basic arithmetic Operators are

int a,b,c;
+ for addition e.g : c= a+b
- for subtraction e.g : c= a-b
* multiplication e.g : c=a*b;
/ division e.g : c=a/b; (5/2=2)
% modulo operator (returns remainder after division)
e.g : c=(a%b); (5%2=1)


Relational Operators:-


It shows the relation between the two variables
e.g : > (greater than)
< (less than)
>=(greater than or equal to)
<= (less than or equal to)
==(equals)
!=(not equal to)
e,g : (a>b),(a=b),(a!=b);


Logical Operators :

&& - Logical AND
e.g.(a>b&&a>c)
|| - Logical OR
e.g.(a>b||a==b)
! - Logical NOT
e.g(!a)


No comments: