Selection sort (code & Algorithm)

Image
I n this blog you have to know all about the Selection sort, Step by step how to work Selection sort Algorithm and also you have to know how to write code in an easy way for selection sort. In Selection sort we are arranging unordered number in a correct order, Examples: This is unordered number (9,6,4,7,3,2,4,5,) but by using selection sort we can arrange in ascending order (2,3,4,5,6,7,9) this is our selection sort, to arrange in an order of given unorder number.       A lgorithm: f C ode for Selection sort: #include <stdio.h> // Function to perform selection sort on an array void selectionSort ( int arr [] , int n ) {     int i , j , min_idx , temp ;     // One by one move boundary of unsorted subarray     for ( i = 0 ; i < n - 1 ; i ++ ) {         // Find the minimum element in unsorted array         min_idx = i ;         for ( j = i + 1 ; j < n...

How to Make Calculator by using "switch case" in c language.

How to Make Calculator
 In c language we can make small calculator by using " Switch case".
Switch case is more understanding as compared to" if......else " case, it is also minimize the block of code and easy to use any where.
Let's Understand.


#include <stdio.h>
int main()
{
//operator like (+,-,*,/) using in switch case :  
    char choice;
    double a, b,c;
 
   
    printf("Enter the any one operator + , - , * , /:");
    scanf("%c", &choice);
    switch (choice)
    {  
    case '+':
        printf("Enter two number for addition:");
        scanf("%lf%lf", &a, &b);
        c = a + b;
        printf("Addition of two number is %lf\n",c);

        break;
    case '-':
        printf("Enter two number for substraction:");
        scanf("%lf%lf", &a, &b);
        c = a - b;
        printf("Substraction of two number is %lf\n", c);

        break;
        case '*':
        printf("Enter two number for multiplication:");
        scanf("%lf%lf", &a, &b);
        c = a * b;
        printf("Multiplication of two number is %.2lf\n", c);
        break;
        case '/':
        printf("Enter two number for division:");
        scanf("%lf%lf", &a, &b);
        c =a / b;
        printf("Division of two number is %lf\n", c);
        break;
    default:
        printf("Typing is wrong");
        break;
    }
    return 0;
}



OUTPUT: Enter the any one operator + , - , * , /:+
                  Enter two number for addition:12
                  23
                  Addition of two number is 35.000000

Click here:








Comments

Popular posts from this blog

Division of Two Number in c language ?

Addition of two Number using c language code