Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Tuesday 30 April 2019

Aptitude Hack#66(30-4-19)

Question:
A zookeeper counted the heads of the animals in a zoo and found it to be 80. When he counted the legs of the animals he found it to be 260. If the zoo had either pigeons or horses, how many horses were there in the zoo? 

A) 40

B) 30

C) 50

D) 60

E) None of These



CLICK HERE 











Monday 29 April 2019

Aptitude Hack#65(29-4-19)

Question:

If 13:11 is the ratio of the present age of Jothi and Viji respectively and 15:9 is the ratio between Jothi's age 4 years hence and Viji's age 4 years ago. Then what will be the ratio of Jothi's age 4 years ago and Viji's age 4 years hence?

 A) 15: 9

 B)  9: 5

 C) 11 : 13

 D) 12:15

 E)  16: 5

Sunday 28 April 2019

IOPP Program No.7. A

Program No.7. A

 Create a LATEX document to demonstrate the paragraph justification (left, center, right) and creating the tables. 

Solution:

\documentclass{article}
\begin{document}
Hi all... I'm new to Perl.

\flushleft Hi, all... I'm new to Perl. 

\center Hi, all... I'm new to Perl.

\flushright Hi, all... I'm new to Perl. 

\begin{center}
\begin{tabular}{|l|c|r|}\hline
left&center&right \\ \hline
1&2&3\\ \hline
left alignment&center allignment&right alignment\\ \hline
\end{tabular}
\end{center}
\end{document}

IOPP Program No.3.A

Program No.3.A

 Write an OpenMP program (for shared memory multiprocessor architecture) to sort the given list of numbers using Radix Sort. Display the appropriate environment variables to demonstrate parallel programming. 

Solution:

#include <stdio.h>
#include<omp.h>
int
main ()
{
  int b, i, j, p, q, d, z = 9, digit = 0, max,n;
  int thread;
  int a[100];
 printf("Enter the Number of Elements U Want TO enter\n");
scanf("%d",&n);
printf("Enter the Elements\n");
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}

  d = 10;
  max = a[0];
  for (i = 1; i < n; i++)
    {
      if (max < a[i])
        {
          max = a[i];
        }
    }
  while (max != 0)
    {
      max = max / 10;
      digit++;
    }
#pragma omp parallel for schedule(static,1) num_threads(9)
  for (z = 0; z < digit; z++)
    {
      for (i = 0; i < n; i++)
        {
          p = a[i] % d;
          for (j = i + 1; j < n; j++)
            {
              q = a[j] % d;
              if (p > q)
                {
                  b = a[i];
                  a[i] = a[j];
                  a[j] = b;
                  p = a[i] % d;
                }

            }
        }

      d = d * 10;
    }
  printf ("The array is:\n");
  for (i = 0; i < n; i++)
    {
      printf ("%d\n", a[i]);
    }
#pragma omp parallel for schedule(static,1) num_threads(9)
  for (i = 0; i < 11; i++)
    {
      thread = omp_get_thread_num ();
      printf ("%d\t  thread:%d\n", a[i], thread);
    }

}

IOPP Program No.6. A

Program No.6. A

 Write an OpenMP program (for shared memory multiprocessor architecture) to multiply the two matrices using the brute force approach. Display the appropriate environment variables to demonstrate parallel programming.

Solution:

#include <stdio.h>
#include<omp.h>
int main()
{
  int r1, r2, c1, c2, i, j, k,tid,nthreads,chunk=10;
  int A[10][10],B[10][10],C[10][10];


  printf("Enter number of rows and columns of first matrix : \n");
  scanf("%d%d", &r1, &c1);
  printf("Enter elements of first matrix : \n");

  for (i = 0; i < r1; i++)
    for (j = 0; j < c1; j++)
      scanf("%d", &A[i][j]);

  printf("Enter number of rows and coluimns of second matrix : \n");
  scanf("%d%d", &r2, &c2);

  if (r2 != c1){
   printf("The matrices can't be multiplied with each other.\n");
   exit(0);
  }

  printf("Enter elements of second matrix : \n");

  for (i = 0; i < r2; i++)
    for (j = 0; j < c2; j++)
      scanf("%d", &B[i][j]);

#pragma omp parallel shared(A,B,C,nthreads,chunk) private(tid,i,j,k)
{
tid = omp_get_thread_num();
if(tid==0)
{
nthreads=omp_get_num_threads();
printf("Starting matrix multiple example with %d threads.\n",nthreads);
}
printf("Thread %d starting matrix multiply...\n", tid);
  #pragma omp for schedule (static,chunk)
    for (i = 0; i < r1; i++) {
      printf("Thread %d did row %d\n",tid,i);
      for (j = 0; j < c2; j++) {
        C[i][j]=0;
        for (k = 0; k < c1; k++) {
          C[i][j] += A[i][k]*B[k][j];
        }
      }
    }
}
    printf("Product of the matrices : \n");

for(i = 0; i < r1; i++)
{
for (j = 0; j < c2; j++)
{
      printf("%d\t", C[i][j]);
}
      printf("\n");

}
  return 0;

}

IOPP Program No.4. A

Program No.4. A

 Write an OpenMP program (for shared memory multiprocessor architecture) to multiply two matrices using Strassen’s Multiplication technique. Display the appropriate environment variables to demonstrate parallel programming. 

Solution:

#include<stdio.h>
int main(){
  int a[2][2],b[2][2],c[2][2],i,j;
  int m1,m2,m3,m4,m5,m6,m7;
  int thread;

  printf("Enter the 4 elements of first matrix: ");
  for(i=0;i<2;i++)
      for(j=0;j<2;j++)
           scanf("%d",&a[i][j]);

  printf("Enter the 4 elements of second matrix: ");
  for(i=0;i<2;i++)
      for(j=0;j<2;j++)
           scanf("%d",&b[i][j]);

  printf("\nThe first matrix is\n");
  for(i=0;i<2;i++){
      printf("\n");
      for(j=0;j<2;j++)
           printf("%d\t",a[i][j]);
  }

  printf("\nThe second matrix is\n");
  for(i=0;i<2;i++){
      printf("\n");
      for(j=0;j<2;j++)
           printf("%d\t",b[i][j]);
  }

#pragma omp parallel num_threads(3)
{
 m1= (a[0][0] + a[1][1])*(b[0][0]+b[1][1]);
  m2= (a[1][0]+a[1][1])*b[0][0];
  m3= a[0][0]*(b[0][1]-b[1][1]);
  m4= a[1][1]*(b[1][0]-b[0][0]);
  m5= (a[0][0]+a[0][1])*b[1][1];
  m6= (a[1][0]-a[0][0])*(b[0][0]+b[0][1]);
  m7= (a[0][1]-a[1][1])*(b[1][0]+b[1][1]);
 thread=omp_get_thread_num();
}
  c[0][0]=m1+m4-m5+m7;
  c[0][1]=m3+m5;
  c[1][0]=m2+m4;
  c[1][1]=m1-m2+m3+m6;

   printf("\nAfter multiplication \n");
   for(i=0;i<2;i++){
      printf("\n");
      for(j=0;j<2;j++){
        printf("%d,thread:%d  ",c[i][j],thread);
   }
}
   return 0;

}

IOPP Program No.8.B

Program No.8.B 

Write a Perl script to convert the decimal number to binary number

Solution:

print"Enter a number to convert : ";
$num=<STDIN>;

$intnum=sprintf("%d",$num);

$i=0;

while($intnum>0)
{
        $array[$i]=$intnum%2;
        $intnum=int($intnum/2);
        $i=$i+1;
}

print "Binary value : ";
for($j=$i;$j>=0;$j--)
{
        print "$array[$j]";

}

IOPP Program No.7.B

Program No.7.B 

Write a Perl script to find the highest marks of a subject. The marks of different subject along with the names of the students are maintained in a “result.txt” file.

Solution:

#!/usr/bin/perl

$filename="result.txt";
open(filedesc,$filename) or die "File can't be opened.";

$maxphy=0;
$maxchem=0;
$maxmath=0;

while(<filedesc>)
{
        @fields=split(':',$_);

        if($fields[1]>$maxphy) {
                $maxphy=$fields[1];
                $namephy=$fields[0];
        }

        if($fields[2]>$maxchem) {
                $maxchem=$fields[2];
                $namechem=$fields[0];
        }

        if($fields[3]>$maxmath) {
                $maxmath=$fields[3];
                $namemath=$fields[0];
        }
}
print"Physics max marks : $maxphy, Name : $namephy\n";
print"Chemistry max marks : $maxchem, Name : $namechem\n";

print"Maths max marks : $maxmath Name : $namemath\n";

IOPP Program No.6.B

Program No.6.B 

 Write a Perl script to copy the contents of one file to another file.

Solution:

open(file1,"<source.txt");
open(file2,">destination.txt");
open(file3,">>appendfile.txt");

while(<file1>)
{
        print file2 $_;
print $_;
        print file3 $_;

}

IOPP Program No.5.B

Program No.5.B 

Write a Perl script to find the average marks of each subject. The marks of the different subject along with the names of the students are maintained in a “result.txt” file.

Solution:

#!/usr/bin/perl

$filename="result.txt";
open(filedesc,$filename) or die "Can't open file.";

$avg=0;
$n=0;
$phytotal=0;
$chemtotal=0;
$mathtotal=0;

while(<filedesc>)
{
        @fields=split(':',$_);
        $physics=$fields[1];
        $chemistry=$fields[2];
        $maths=$fields[3];

        $phytotal=$phytotal+$physics;
        $chemtotal=$chemtotal+$chemistry;
        $mathtotal=$mathtotal+$maths;

        $n=$n+1;
}
$phyavg=$phytotal/$n;
print "Physics average=$phyavg\n";
$chemavg=$chemtotal/$n;
print "Chemistry average=$chemavg\n";
$mathavg=$mathtotal/$n;

print "Maths average=$mathavg\n";

IOPP Program No.4.B

Program No.4.B 

 Write a shell script that displays “Good morning”, “Good afternoon” or “Good evening”, depending upon the time at which the user logs in. 

Solution:

echo "Greeting of the day."
x=`date | cut -c 12-13`
echo $x
y=`date | cut -c 12-16`
echo $y

if [ $x -ge 0 ] && [ $x -lt 10 ]
then
echo "Good morning."
elif [ $x -ge 10 ] && [ $x -lt 14 ]
then
echo "Good afternoon."
elif [ $x -ge 14 ] && [ $x -lt 20 ]
then
echo "Good evening."
else
echo "Good night."

fi

IOPP Program No.3. B

Program No.3. B 

Write a shell script to display the lines of a given file. The line numbers are specified as a range. For example, if the range specified is 10-25, then the lines from 10 to 25 of the file are to be displayed. 

Solution:

echo "Enter the filename."
read filename
echo "Enter the starting line."
read x
echo "Enter the ending line."
read y
if [ $x -gt $y ]
then
echo "ERROR: Ending Line Should Greater Starting Line"
exit
fi
sed -n $x,$y\p $filename > cat > newline
cat newline

IOPP Program No.2.B

Program No.2.B 

Write a shell script to check whether a number is a palindrome or not.


Solution:

echo "Enter a number."
read n
p=$n
sd=0
rev=0
while [ $n -gt 0 ]
do
    sd=$(( $n % 10 ))
    rev=`expr $rev \* 10 + $sd`
    n=$(( $n / 10 ))
done
if [ $p -eq $rev ]
then
echo "Palindrome."
else
echo "Not Palindrome."
fi

IOPP Program No.2.A

Program No.2. a)

 Write OpenMP program (for shared memory multiprocessor architecture) to sort the given list of names using Bubble Sort. Display the appropriate environment variables to demonstrate parallel programming.

Solution:
#include<stdio.h>
#include<stdlib.h>
#include<omp.h>
#include<string.h>
int main(int argc,char **argv)
{
        int i,j,tid,nthreads,n,chunk=10;
        char name[20][10],t_name[20][10],temp[10];
        printf("Enter how many names to be sorted:\n");
        scanf("%d",&n);
        printf("Enter names one by one :\n");
        for(i=0;i<n;i++) {
                scanf("%s",name[i]);
                strcpy(t_name[i],name[i]);
        }
        #pragma omp parallel shared (name,t_name,temp,nthreads,chunk) private(tid,i,j)
        {
        tid = omp_get_thread_num();
        if(tid==0) {
        nthreads=omp_get_num_threads();
        printf("Starting bubble sort example with %d Threads.\n", nthreads);
        }
        printf("Thread %d starting bubble sort.\n", tid);
        #pragma omp parallel for schedule(static,chunk)
        for(i=0;i<n-1;i++)
        {
                for(j=0;j<n-i-1;j++)
                {
                        if(strcmp(name[j],name[j+1])>0)
                        {
                                strcpy(temp,name[j]);
                                strcpy(name[j],name[j+1]);
                                strcpy(name[j+1],temp);
                        }
                }
        }
        printf("Thread %d ending bubble sort.\n", tid);
        }

        printf("List before Sorting :\n");
        for(i=0;i<n;i++)
                printf("%s\n",t_name[i]);

        printf("List after Sorting :\n");
        for(i=0;i<n;i++)
                printf("%s\n",name[i]);

}

IOPP Program No.1.B

Program No.1.B

 Write a shell script to determine the type of triangle. 

Solution:

echo "Enter the first side of the triangle."
read x
echo "Enter the second side of the triangle."
read y
echo "Enter the third side of the triangle."
read z

if [ $x -eq $y ] &&  [ $y -eq $z ] 
then
echo "Equilateral triangle."

elif [ $x -eq $y ]  ||  [ $y -eq $z ] ||  [ $x -eq $z ] 
then
echo "Isoceles triangle."
else
echo "Scalene triangle."

fi

IOPP Program NO.1 A

Program No.1.A

Demonstrate the following coding standards by writing a C program to evaluate a postfix evaluation:
 1. Naming convention.
 2. Active Names for functions.
 3. Consistent indentations and brace styles. 
4. Proper parenthesizing to resolve the ambiguity. 
5. Proper documentation. 

Solution:

#include<stdio.h>

struct stack{
int array[20];
int top;
}s;

void push(int element)
{
        s.array[++s.top] = element;
}

int pop()
{
        return s.array[s.top--];
}

int main()
{
        char exp[20];
        char *e;
        int n1,n2,n3,num;
        s.top=-1;
        printf("Enter the expression :: ");
        scanf("%s",exp);
        e = exp;
        while(*e != '\0')
        {
                if(isdigit(*e))
                {
                        num = *e - 48;
                        push(num);
                }
                else
                {
                        n1 = pop();
                        n2 = pop();
                        switch(*e)
                        {
                                case '+':
                                {
                                        n3 = n1 + n2;
                                        break;
                                }
                                case '-':
                                {
                                        n3 = n2 - n1;
                                        break;
                                }
                                case '*':
                                {
                                        n3 = n1 * n2;
                                        break;
                                }
                                case '/':
                                {
                                        n3 = n2 / n1;
                                        break;
                                }
                        }
                        push(n3);
                }
                e++;
        }
        printf("\nThe result of expression %s  =  %d\n\n",exp,pop());
        return 0;


}

Aptitude Hack#64(28-4-19)

Question:
The price of 2 sarees and 4 shirts is Rs. 1600. With the same money, one can buy 1 saree and 6 shirts. If one wants to buy 12 shirts, how much shall he have to pay?

A. Rs. 1200

B. Rs. 2400

C. Rs. 4800

D. Cannot be determined

E. None of these

Saturday 27 April 2019

Tricky Interview#2

Question:

Write a function that moves the last element to the front in a given Singly Linked List.

 For example:

Input Linked List is 1->2->3->4->5.
Output Linked List 5->1->2->3->4.

Solution:

Move last element to front of a given Linked List

Question:
Write a function that moves the last element to the front in a given Singly Linked List.

 For example:

Input: 1->2->3->4->5

Output: 5->1->2->3->4.



Algorithm:

Traverse the list till the last node. Use two pointers: one to store the address of the last node and other for the address of the second last node. After the end of the loop do the following operations.
i) Make second last as last (secLast->next = NULL).
ii) Set next of last as head (last->next = *head_ref).
iii) Make last as head ( *head_ref = last)



 C Program :

#include<stdio.h>
#include<stdlib.h>
struct Node
{
    int data;
    struct Node *next;
};

void moveToFront(struct Node **head_ref)
{
    /* If linked list is empty, or it contains only one node,
      then nothing needs to be done, simply return */
    if (*head_ref == NULL || (*head_ref)->next == NULL)
        return;

    /* Initialize second last and last pointers */
    struct Node *secLast = NULL;
    struct Node *last = *head_ref;

    /*After this loop secLast contains address of second last
    node and last contains address of last node in Linked List */
    while (last->next != NULL)
    {
        secLast = last;
        last = last->next;
    }

    /* Set the next of second last as NULL */
    secLast->next = NULL;

    /* Set next of last as head node */
    last->next = *head_ref;

    /* Change the head pointer to point to last node now */
    *head_ref = last;
}

/* UTILITY FUNCTIONS */
/* Function to add a node at the begining of Linked List */
void push(struct Node** head_ref, int new_data)
{
    /* allocate node */
    struct Node* new_node =
        (struct Node*) malloc(sizeof(struct Node));

    /* put in the data  */
    new_node->data  = new_data;

    /* link the old list off the new node */
    new_node->next = (*head_ref);

    /* move the head to point to the new node */
    (*head_ref)    = new_node;
}


/* Function to print nodes in a given linked list */
void printList(struct Node *node)
{
    while(node != NULL)
    {
        printf("%d ", node->data);
        node = node->next;
    }
}

int main()
{
    struct Node *start = NULL;

    push(&start, 5);
    push(&start, 4);
    push(&start, 3);
    push(&start, 2);
    push(&start, 1);

    printf("\n Linked list before moving last to the front\n");
    printList(start);

    moveToFront(&start);

    printf("\n Linked list after removing last to the  front\n");
    printList(start);

    return 0;
}


Output:
 Linked list before moving last to the front
1 2 3 4 5
 Linked list after removing last to the front
5 1 2 3 4



Aptitude Hack#63(27-4-19)

Question:

A hollow iron pipe is 21 cm long and its external diameter is 8 cm. If the thickness of the pipe is 1 cm and iron weighs 8 g/cm3, then the weight of the pipe is:

A. 3.6 kg

B. 3.696 kg

C. 36 kg

D. 36.9 kg

Friday 26 April 2019

Aptitude Hack#62(26-4-19)

Question:
A bag contains 4 white, 5 red, and 6 blue balls. Three balls are drawn at random from the bag. The probability that all of them are red is:

A)1/22

B) 3/22

C) 2/91



D) 2/77
\



Thursday 25 April 2019

Aptitude Hack#61(25-4-19)

Question:
 The area of a square is 196 sq cm whose side is half of the radius of a circle. The circumference of the circle is equal to the breadth of a rectangle if the perimeter of a rectangle is 712 cm. What is the length of the rectangle?  

A) 196 cm

B) 186 cm

C) 180 cm

D) 190 cm 

E)  None of these


Wednesday 24 April 2019

Aptitude Hack#60(24-4-19)

Question:

What is the sum of two consecutive odd numbers, the difference of whose squares is 56?

A) 30

B) 28

C) 34

D) 32


Tuesday 23 April 2019

Aptitude Hack#59(23-4-19)

Question:





  



A) 1.45

B) 1.88

C) 2.9

D) 3.7


Monday 22 April 2019

Aptitude Hack#58(22-4-19)

Question:
There are two examinations rooms A and B. If 10 students are sent from A to B, then the number of students in each room is the same. If 20 candidates are sent from B to A, then the number of students in A is double the number of students in B. The number of students in room A is:

A. 20

B. 80

C. 100

D. 200

Sunday 21 April 2019

Aptitude Hack#57(21-4-19)

Question:

In a shower, 5 cm of rain falls. The volume of water that falls on 1.5 hectares of the ground is:

A) 75 

B) 750 

C) 7500 

D) 75000 

Saturday 20 April 2019

Aptitude Hack#56(20-4-19)

Question:

A certain amount earns simple interest of Rs. 1750 after 7 years. Had the interest been 2% more, how much more interest would it have earned?

A) Rs. 35

B) Rs. 245

C) Rs. 350

D) Cannot be determined

Friday 19 April 2019

Aptitude Hack#55(19-4-19)

Question:

In class, there are 15 boys and 10 girls. Three students are selected at random. The probability that 1 girl and 2 boys are selected, is:

A) 21/46

B) 25/117

C)1/50

D) 3/25

Thursday 18 April 2019

Aptitude Hack#54(18-4-19)

Question:
 Amit has a certain average for 9 innings. In the tenth innings, he scores 100 runs thereby increasing his average by 8 runs. His new average is:

A) 20
B) 21
C) 28
D) 32 

Wednesday 17 April 2019

Aptitude Hack#53(17-4-19)

Question:
What will be the next element in the given series
9, 25, 49, 121, ...

A)169
B)225
C)196
D)221

Monday 15 April 2019

Aptitude Hack#51(15-4-19)

Question:

P, Q, and R can do a piece of work in 40, 60 and 120 days respectively. In how many days can P do the work if he is assisted by Q and R on every fourth day?

A) 83/3 days
B) 3/5 days
C) 80/3 days
D) 4/3 days

Sunday 14 April 2019

Aptitude Hack#50(14-4-19)

Question:

Which number does not belong in the series below? 

2, 5, 10, 17, 26, 37, 50, 64

A) 17
B) 37
C) 64
D) 26

Saturday 13 April 2019

Aptitude Hack#49(13-4-19)

Question:
8 litres are drawn from a cask full of wine and is then filled with water. This operation is performed three more times. The ratio of the quantity of wine now left in cask to that of water is 16 : 65. How much wine did the cask hold originally?
A. 18 litres
B. 24 litres
C. 32 litres
D. 42 litres

Friday 12 April 2019

Integer Promotions in C

Integer Promotions in C

Some data types like char, short int take less number of bytes than int, these data types are automatically promoted to int or unsigned int when an operation is performed on them. This is called integer promotion. For example, no arithmetic calculation happens on smaller types like char, short and enum. They are first converted to int or unsigned int, and then arithmetic is done on them. If an int can represent all values of the original type, the value is converted to an int. Otherwise, it is converted to an unsigned int.

For example see the following program:

#include <stdio.h>
int main()
{
    char a = 30, b = 40, c = 10;
    char d = (a * b) / c;
    printf ("%d ", d);
    return 0;
}

Output:

120
At first look, the expression (a*b)/c seems to cause arithmetic overflow because signed characters can have values only from -128 to 127 (in most of the C compilers), and the value of subexpression ‘(a*b)’ is 1200 which is greater than 128. But integer promotion happens here in arithmetic done on char types and we get the appropriate result without any overflow.



Aptitude Hack#48(12-4-19)

Question:
The angle of elevation of a ladder leaning against a wall is 60° and the foot of the ladder is 4.6 m away from the wall. The length of the ladder is:

A) 2.3 m
B) 4.6 m
C) 7.8 m
D) 9.2 m

Thursday 11 April 2019

Tricky Interview #1

Question:

W A C Program That Prints All The vowels Given In String Without Using IF and Break Statements In program? 

Submit Ur Answers (Follow The Link)

Link: https://docs.google.com/forms/d/e/1FAIpQLSeBXalNTB5cLX8dC8BlFmzGcItV52GBiUkqaaCM2q_bpaDnKg/viewform?usp=sf_link




Aptitude Hack#47(11-3-19)

Question:
From a group of 7 men and 6 women, five persons are to be selected to form a committee so that at least 3 men are there on the committee. In how many ways can it be done?

A) 564
B) 645
C) 735
D) 756


Wednesday 10 April 2019

Aptitude Hack#46(10-4-19)

Question:

Find out the wrong number in the given sequence of numbers.
36, 54, 18, 27, 9, 18.5, 4.5

A) 4.5

B) 18.5
  
C) 54

D) 18



Tuesday 9 April 2019

Generic Storing of Number

Question:
Write a Java program the implements a generic sort method using any of the sorting techniques.

Solution:

public class Students{

   public static <T extends Comparable<T>> void sortingMethod(Number[] i2)   {

    int i,j,n;

    n=i2.length;

    for(i=0;i<n;i++)

     for(j=0;j<n-i-1;j++)

      if(((Comparable<T>) i2[j]).compareTo((T) i2[j+1])>0)

      {

       T temp;

       temp=(T) i2[j];

       i2[j]=i2[j+1];

       i2[j+1]=(Number) temp;

      }

    System.out.println();

    System.out.println("After Sorting The Elements");

    for(Number element: i2)

    System.out.printf("%s, ", element);

   }

   public static void main(String args[])

   {

    Number i[]={3.2,2.5,10.02,7.012,7.06};

    System.out.println("Before Sorting The Elements");

    for(Number element:i)

     System.out.printf("%s, ",element);

    sortingMethod(i);

   }



}





Output:

Before Sorting The Elements

3.2, 2.5, 10.02, 7.012, 7.06, 

After Sorting The Elements

2.5, 3.2, 7.012, 7.06, 10.02, 



Credits: Gaurav