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    ...

Strings in C


A string is a series of characters treated as a single unit. A string may include letters, digits and various special characters such as +, -, *, / and $. String literals, or string constants in C are written in double quotations marks.

A string in C is an array of characters ending in the null character (‘\0’). There is null character at end of each and every string which indicates ending or termination of a string. Format String specifier is %s in printf and scanf. The value of string is address of its first character. 
Declaration and initialization of string can be done by using either a character array or a variable of type char pointer as shown below:
Char color[] = “blue”;
Char *colorptr = “blue”;

In which each initialize a variable to the string “blue”. The first declaration creates five element array color containing the characters ‘b’, ‘l’, ‘u’, ‘e’ and ‘\0’. The second declaration creates pointer variable colorptr that points to the string “blue” somewhere in memory.

The declaration and initialization of string char color[] = “blue” could also be written as:
 char color[] = { ‘b’, ‘l’, ‘u’, ‘e’, ‘\0’ };.









Comments

Popular posts from this blog

simple calculator apps project in android studio

Arrays in C Programming Language

Pointers in C