Skip to main content

Posts

Showing posts from September, 2017

C Program to Sort Elements in Lexicographical Order (Dictionary Order)

#include #include int main () { int i , j ; char str [ 10 ][ 50 ], temp [ 50 ]; printf ( "Enter 10 words:\n" ); for ( i = 0 ; i < 10 ; ++ i ) scanf ( "%s[^\n]" , str [ i ]); for ( i = 0 ; i < 9 ; ++ i ) for ( j = i + 1 ; j < 10 ; ++ j ) { if ( strcmp ( str [ i ], str [ j ])> 0 ) { strcpy ( temp , str [ i ]); strcpy ( str [ i ], str [ j ]); strcpy ( str [ j ], temp ); } } printf ( "\nIn lexicographical order: \n" ); for ( i = 0 ; i < 10 ; ++ i ) { puts ( str [ i ]); } return 0 ;   }  https://www.jdoodle.com/embed/v0/c/gcc-5.3.0/6WK

C++ program to implement Booth's multiplier

  1  #include <iostream>   2  #include <windows.h>   3  #include <fstream>   4  #include <math.h>   5  #define pause system("pause");   6  using namespace std ;   7  const int no_of_bits = 32 ;   8  /* this Program uses Following notations.... first bit for signed and then it goes like this 1 2 4 8 16 32 64......   9  /* ----------------------------------------global variables ----------------------------------  10  */  11  int Q1 = 0 ; /// extra bit holder  12  int A [ no_of_bits ]; /// Accumulator storing array  13  int Q [ no_of_bits ]; /// Multiplier storing Array.  14  int N , Qsize ; /// no of bits in multiplier  15  int X ; /// no of bits in multiplicand.  16  int M [ no_of_bits ]; /// M value  17  int M2Complement [ no_of_bits ]; /// -M  18  int temp [ no_of_bits ]; /// for temporary use  19  ofstream out ;  20   21  /*  22  ...............................................now function ..................