How recursive bubble sort work

                                              Recursive Bubble Sort Base Case: If array size is 1, return. Do One Pass of normal Bubble Sort. This pass fixes last element of current subarray. Recur for all elements except last of current subarray. Example: Index=     0 1  2 3 4 5 6 7   100                          90 80 70 60 50 40 30  Array []= Suppose we want to sort the above in the increasing order by the recursive bubble sort. Make a get grater which will return the grater of the array. Compare the first and last element of the array if the first is greater than last the swap with each other. And again call the sort function and decrement the array size by 1; 1) 30                     90 80 70 60 50 40 100    ...

Relational and Logical Operators, Decision or Selection Statements


Relational Operators used in decision or selection statements. It compares status of one variable with another variable value as greater than, less than or equal to. Following is a list of relational operators:

Operator Name
Syntax
Less than or equal to
<=
Greater than
>
Less than
<
Greater than or equal to
>=
Equal to
==
Not equal to
!=

Logical Operators used in decision or selection statements and are three in number such as &&, ||, and ! read as AND, OR and NOT respectively. The first two logical operators allow two or more conditions to be combined in if-statement. The following table shows logical operators:

Logical operators
Syntax
Logical AND
a && b
Logical OR
a || b
Logical Negation (NOT)
!a
 
if statement  is used to take decision about specific condition to execute. The body of if-statement is executed if value of the expression or condition specified in the if-statement is true. For example if there is raining outside, I will take umbrella so here condition is rain for which umbrella must be taken in case to go outside. 

Syntax of if-statement is as follows:


if (condition)
           {

                           Block of statements;
           
           }

if-else statement is similar to if-statement with an addition of else statement. If the condition is false in if-statement, then if-statement body will be skipped and else body will be executed. For example if there is raining outside, I will take an umbrella else I will go outside without an umbrella. So when first condition doesn’t satisfy then second condition will be followed. Syntax of if-else statement is as follow:

if (condition)
           {
                      Block of statements;
           }
         Else
           {
Block of statements;
            }
           
switch statement allows us to make a decision from a number of choices. The syntax for switch statement is as follows:

switch (integer expression)
{
     Case constant 1:
       Do this;
     Break;
                     Case constant 2:
       Do this;
      Break;
     Default;
       Do this;
     Break;
}
The integer expression can be any C expression that yields to integer value and could be an integer constant like 1, 2, 3 or an expression that evaluates to an integer value. case is keyword and must be followed by integer or character constant and constant in case must be different from all other constants.



Comments

Popular posts from this blog

simple calculator apps project in android studio

Arrays in C Programming Language

Pointers in C