Skip to main content

Posts

Showing posts from September 14, 2009

Selection Sort

/**     Program Name: Selection Sort     Description: This Program sort a given array elements, using Selection                    Sort Algorithm     Author:  Tauqirul Haque         */ #include <conio.h> #include <stdio.h> #define MAX 5 void selectionSort(int *, int ); void display(int *); void main() {     int array[MAX] = { 35,56,23,11,46 };         printf("\nThe Array Before Sortint .... \n");     display(array);         selectionSort(array,MAX);         printf("\n\nThe Array After Sorting .. \n");     display(array);     } void selectionSort(int *array, int array_size) {   int i, j;   int min, temp;   for (i = 0; i < ar...

SWAP Two Values without using temporary variable

/**     Program Name: Swap Two Numbers     Description: This Program swaps two number, using XOR     Author:  Tauqirul Haque        */ #include <stdio.h> #include <conio.h> int main() {     int firstNumber, secondNumber;        printf("Enter The First Number :  ");     scanf("%d",&firstNumber);        printf("\nEnter The Second Number :  ");     scanf("%d",&secondNumber);        printf("\n\nNumbers Before Swapping :  %d  <-> %d \n",firstNumber, secondNumber);        firstNumber = firstNumber^secondNumber;     secondNumber = firstNumber^secondNumber;     firstNumber = firstNumber^secondNumber;        printf("\nNumbers After Swapping : ...

BIT AND Operation

/**     Program Name: AND Operation Between To Binary Numbers     Description: This Program Converts A Decimal Number to its Binary                        Equivalent, using shift Operator, and also performs the                       "logical And" operation between them, and displays output.                      Author:  Tauqirul Haque         */ void printBinary(int i); int main() {     int number, number2;     printf("Enter The Number : ");     scanf("%d",&number);         printf("Enter The Number : ");     scanf("%d",...