Neer Varshney
Last Activity: 12 Years ago
u may refer book for these definitions written by sumita arora, these are given very well there though i may tell you in short:
1.
if/else: it is used to check if a condition is true or not.
for ex. if i want to check if a number is even or odd... and if odd multiply by 2.
we will do it like this:
int a;
if(a%2==0)
{
//no. is even so we will not do anything
}
else
{
a*=2; // no. is odd so multiply by 2
}
2.
if we use one more if inside an if than we call it nested if...
it is used if i have to do the following:
if i want to check if a number is even or odd... and if odd multiply by 2 and if even than check if it greater than 5 and than multiply by 2.
we will do it like this:
int a;
if(a%2==0)
{ if(a>5)
{a*=2;}
}
else
{
a*=2; // no. is odd so multiply by 2
}
3.
switch do the same work as of if-else.. it is used when we have multiple conditions to check,.,,
format:
switch(a)
{
case 1:
break;
case 2:
break;
case 3:
break;
default:
exit(0);
}
4.class
it is a collection of dissimilar data types, by default all members are private...it implements the concepts of OOP(object oriented programming).