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

Multiplication of two number by using C Programs

Multiplication of two number by using C Programs

 Let's Understand Step by Step:

Algorithm:
  1. Start: Take two numbers, a and b.

  2. Initialize: Set a result variable, result, to 0.

  3. Loop: Iterate until one of the numbers (say b) is 0.

    • If b is odd, add a to result.

    • Double a (i.e., a=a×2).

    • Halve b (i.e., b=b/2).

  4. End: The result now contains the product of a and b.

 
Flow chart:
             
Program for multiplication:
  
#include<stdio.h>

int main()
{
    int a,b,c;

   
printf("enter two number:");
   
scanf("%d %d", &a,&b);
   
c = a * b;
   
printf("multiplication of %d * %d is %d", a,b,c);

return 0;


}

Output:
enter two number:12
12
multiplication of 12 * 12 is 144

Question for you -
  Multiplication of two numbers a=15 and b=9
Solve and comments your Answers in comment box.
see this video:




Comments

Popular posts from this blog

Division of Two Number in c language ?

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

Addition of two Number using c language code