Flag Discuss with Askiitians Tutors> informatics pratice...
question mark

what is method , class, switch , if else nested if,etc.

rajan shri , 12 Years ago
Grade
anser 1 Answers
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).

Provide a better Answer & Earn Cool Goodies

Enter text here...
star
LIVE ONLINE CLASSES

Prepraring for the competition made easy just by live online class.

tv

Full Live Access

material

Study Material

removal

Live Doubts Solving

assignment

Daily Class Assignments


Ask a Doubt

Get your questions answered by the expert for free

Enter text here...