Skip to main content

Posts

Showing posts from November, 2014

Binary Search in C using Recursion

#include<stdio.h> void bins ( int lb , int ub , int item , int a []); void main () { int i , n , item , a [ 20 ]; printf ( "Enter the size of an array: " ); scanf ( "%d" , & n ); printf ( "Enter the elements of the array: " ); for ( i = 0 ; i < n ; i ++ ) { scanf ( "%d" , & a [ i ]); } printf ( "Enter the number to be search: " ); scanf ( "%d" , & item ); bins ( 0 , n - 1 , item , a ); } void bins ( int lb , int ub , int item , int a []) { int mid , flag = 0 ; if ( lb <= ub ) { mid = ( lb + ub ) / 2 ; if ( item == a [ mid ]) { flag = flag + 1 ; } else if ( item < a [ mid ]) { return bins ( lb , mid - 1 , item , a ); } else return bins ( mid + 1 , ub , item , a ); } if (

Using the concept of Inheritance write a C++ Program to calculate the area and perimeter of rectangle

/* C++ Program to calculate the area and perimeter of rectangles using concept of inheritance. */ #include using namespace std; class Rectangle { protected: float length, breadth; public: Rectangle(): length(0.0), breadth(0.0) { cout<<"Enter length: "; cin>>length; cout<<"Enter breadth: "; cin>>breadth; } }; /* Area class is derived from base class Rectangle. */ class Area : public Rectangle { public: float calc() { return length*breadth; } }; /* Perimeter class is derived from base class Rectangle. */ class Perimeter : public Rectangle { public: float calc() { return 2*(length+breadth); } }; int main() { cout<<"Enter data for first rectangle to find area.\n"; Area a; cout<<"Area = "<

Java Program to implement Thread

class   A     extends    Thread                                                                               {                 public  void  run( )                                                                                                {                                 for(  int i = 1 ;   i <= 5  ;    i++   )                                                  System.out.println( "   From thread A :  i  =   "  +   i  ) ;                                  System.out.println( " End of thread A  "  )  ;                      }        } class    B    extends     Thread                                                                              {                 public  void  run( )                                                                                                {                                 for(  int j = 1 ;   j <= 5  ;   j++ )                                                  System.out.println(   "   From thread B :    j =   "    

8085 Programming : store the nos in a memory loc. In the reverse order in another memory location

               MVI C, 0AH  ; Initialize counter                   LXI H, 2200H  ; Initialize source memory pointer                   LXI D, 2309H  ; Initialize destination memory pointer    BACK:    MOV A, M  ; Get byte from source memory block                   STAX D  ; Store byte in the destination memory block                   INX H  ; Increment source memory pointer                   DCX D  ; Decrement destination memory pointer                    DCR C  ; Decrement counter                    JNZ BACK  ; If counter  0 repeat                   HLT ; Terminate program execution

8085 Programming : In a set of nos add only the odd nos

                 LDA 2200H              MOV C, A  ; Initialize counter              LXI H, 2201H  ; Initialize pointer              MVI E, 00  ; Sumlow = 0              MOV D, E ; Sumhigh = 0   BACK:      MOV A, M  ; Get the number              ANI 01H   ; Mask Bit1 to Bit7              JZ SKIP                  ; Do not add if number is even              MOV A, E  ; Get the lower byte of sum                    ADD M     ; Sum = sum + data              MOV E, A   JNC SKIP  ; Store result in E register              INR D   ; Add carry to MSB of SUM   SKIP:        INX H   ; Increment pointer              DCR C     ; Decrement counter             JNZ BACK  ; Check if counter 0 repeat             MOV A, E             STA 2300H  ; Store lower byte             MOV A, D             STA 2301H ; Store higher byte            HLT ; Terminate program execution     

8085 Programming : In a set of nos add only the even nos

            LDA 2200H         MOV C, A  ; Initialize counter               MVI B, 00H ; sum  =  0         LXI H, 2201H ; Initialize pointer   BACK: MOV A, M  ; Get the number         ANI, 01H   ; Mask Bit1 to Bit7         JNZ SKIP  ; Don’t add if number is ODD         MOV A, B  ; Get the sum         ADD M  ; SUM = SUM + data         MOV B, A  ; Store result in B register   SKIP:   INX  H        ; increment pointer         DCR C ; Decrement counter         JNZ BACK  ; if counter 0 repeat         STA 2210H ; store sum         HLT    ; Terminate program execution  

8085 Programming : To find the no of 1’s in the byte

            MVI B,00H                 MVI C,08H                MOV A,D    BACK: RAR                JNC SKIP                INR B    SKIP:   DCR C                JNZ BACK                HLT       

8085 Programming : Block data transfer

              MVI C, 0AH  ; Initialize counter                  LXI H, 2200H  ; Initialize source memory pointer                  LXI D, 2300H  ; Initialize destination memory pointer    BACK:   MOV A, M  ; Get byte from source memory block                  STAX D  ; Store byte in the destination memory block                  INX H  ; Increment source memory pointer                  INX D  ; Increment destination memory pointer                   DCR C  ; Decrement counter                   JNZ BACK  ; If counter  0 repeat                  HLT ; Terminate program execution   

8085 Programming : Adding 2 Hexa-Decimal nos with carry

             LDA 2200H                 MOV C,A ; Initialize counter                 LXI H, 2201H ; Initialize pointer                 SUB A  ; Sum low = 0                 MOV B,A ;  Sumhigh  = 0    BACK:  ADD M ; Sum = sum + data                 JNC SKIP                 INR B   ; Add carry to MSB of SUM   SKIP:    INX H   ; Increment pointer               DCR C ; Decrement counter               JNZ BACK  ; Check if counter 0 repeat               STA 2300H              MOV A,B  ; Store lower byte               STA 2301H  ; Store higher byte               HLT   ; Terminate program execution

8085 Programming : Adding 2 Hexa-decimal nos without carry

  LDA 2200              MOV C, A ;  Initialize counter              SUB A  ;  sum = 0              LXI H, 2201H ;  Initialize pointer BACK:  ADD M   ; SUM = SUM + data              INX H  ;  increment pointer              DCR C ;  Decrement counter              JNZ BACK ;  if counter  0 repeat              STA 2300H ;  store sum              HLT          

8085 Programming: Adding 2 BCD nos without carry

MOV A, L ; Get lower 2 digits of no. 1    ADD E ; Add two lower digits    DAA  ; Adjust result to valid BCD    STA 2300H ; Store partial result    MOV A, H ; Get most significant 2 digits of no. 2    ADC D ; Add two most significant digits     DAA  ; Adjust result to valid BCD     STA 2301H ; Store partial result    HLT ; Terminate program execution   

8085 Programming : ADDITION OF 16BIT NUMBERS

ADDITION OF TWO 16BIT NUMBERS SUM 16 BITS OR MORE Manually strore 1st 16 bit no in the memory location C050 & C051 in reverse order Manually store 2nd 16 bit no in the memory location C052 & C053 in reverse order Result is stored in C053, C054 & C055 in reverse order           LHLD C050          XCHG          LHLD C052          MVI C,00          DAD D          JNC AHEAD          INR C AHEAD:   SHLD C054         MOV A,C         STA C056         HLT EXAMPLE-> A645+9B23=014168 STORE-> C050=45,C051=A6,C052=23,C053=9B Answer-> C054=68,C055=41,C056=01 // 45H,A6H,23H,9BH

8085 Programming : 8 BIT DECIMAL SUBSTRACTION

  If 2nd no is greater than 1st no then the answer will in 2's complement Manually strore 1st 8 bit no in the memory location C050 Manually store 2nd 8 bit no in the memory location C051 Result is stored in C052   LXI H,C051   MVI A,99   SUB M   INR A   DCX H   ADD M   DAA   STA C052   HLT  EXAMPLE-> 99-48=51  STORE-> C050=99,C051=48 OUTPUT: C052=51

8085 Programming: Exchange the contents of memory locations

Exchange the contents of memory locations 2000H and 4000H. Program 1: LDA 2000H : Get the contents of memory location 2000H into accumulator MOV B, A : Save the contents into B register LDA 4000H : Get the contents of memory location 4000H into accumulator STA 2000H  : Store the contents of accumulator at address 2000H MOV A, B : Get the saved contents back into A register STA 4000H : Store the contents of accumulator at address 4000H Program 2: LXI H 2000H : Initialize HL register pair as a pointer to memory location 2000H. LXI D 4000H : Initialize DE register pair as a pointer to memory location 4000H. MOV B, M  : Get the contents of memory location 2000H into B register. LDAX D : Get the contents of memory location 4000H into A register. MOV M, A : Store the contents of A register into memory location 2000H. MOV A, B : Copy the contents of B register into accumulator. STAX D : Store the contents of A register into memory location 4000H. HLT : Terminate program execution. Note: In Pr

8085 Programming: Store 8 bit data in Memory

Program 1: MVI A, 52H : Store 32H in the accumulator STA 4000H : Copy accumulator contents at address 4000H HLT : Terminate program execution Program 2: LXI H : Load HL with 4000H MVI M : Store 32H in memory location pointed by HL register pair (4000H) HLT : Terminate program execution Note: The result of both programs will be the same. In program 1 direct addressing instruction is used, whereas in program 2 indirect addressing instruction is used.

8085 Programming: 8 BIT MULTIPLICATION: PRODUCT 16-BIT

       LHLD 2501        XCHG        LDA 2503        LXI H,0000        MVI C,08 LOOP:     DAD H        RAL        JNC AHEAD        DAD D AHEAD:  DCR C        JNZ LOOP        SHLD 2504        HLT LSB OF MULTIPLICAND - 84H, MSB OF MULTIPLICAND - 00H ,MULTIPLIER - 56H ANSWER AT ADDRESS 2504 - 58H, LSBs OF PRODUCT AT ADDRESS 2505 - 2CH, MSB sOF PRODUCT

8085 Programming: 8 BIT DIVISION

      LHLD 2501       LDA 2503       MOV B,A       MVI C,08 LOOP:   DAD H      MOV A,H      SUB B      JC AHEAD      MOV H,A      INR L AHEAD: DCR C       JNZ LOOP       SHLD 2504       HLT INPUT: LSB OF DIVIDEND - 9BH, MSB OF DIVIDEND - 48H , DIVISOR - 1AH ANSWER AT ADDRESS 2504 - F2H, QUOTIENT AT ADDRESS 2505 - 07H, REMAINDER

8085 Programming: 2's COMPLEMENT OF AN 8-BIT NUMBER

The number to be complemented is stored in C050. Answer is stored in C051   LDA C050   CMA   INR A   STA C051   HLT EXAMPLE-> C050=96 Answer-> C051=6A

8085 Programming: 2's COMPLEMENT OF A 16-BIT NUMBER

The 16bit number is stored in C050,C051. The answer is stored in C052,C053   LXI H,C050   MVI B,00   MOV A,M   CMA   ADI 01   STA C052   JNC GO   INR B GO:   INX H   MOV A,M   CMA   STA C053   HLT EXAMPLE-> C050=8C,C051=5B Answer-> C052=74,C053=A4

8085 Programming: 1's COMPLEMENT OF AN 8-BIT NUMBER

The number to be complemented is stored in C050. Answer is stored in C051   LDA C050   CMA   STA C051   HLT EXAMPLE-> C050=96 Answer-> C051=69

8085 Programming: 1's COMPLEMENT OF A 16-BIT NUMBER

The 16bit number is stored in C050,C051 The answer is stored in C052,C053   LXI H,C050   MOV A,M   CMA   STA C052   INX H   MOV A,M   CMA   STA C053   HLT  EXAMPLE-> C050=85,C051=54  Answer-> C052=7A,C053=AB

8085 Programming :

Nokia's first device to the post Microsoft era

Nokia isn't exactly known for its tablets, but having sold its phone-making division to Microsoft it's hoping to catch your eye with its latest compellingly priced Android offering. The Nokia N1 starts at $250 and is set to go on sale in China before the Chinese New Year -- that's February 19, 2015. Information on other international pricing and release dates have yet to be announced, but the US dollar price converts to around £160 or AU$290. The N1 looks trendy and slim. It's 6.9mm thick and an aluminum frame that comes in dark gray or silver. Its 7.9-inch IPS LCD screen boasts a 4:3 aspect ratio with a 2,048x1,536-pixel resolution. Inside you'll find a 64-bit 2.3GHz Intel Atom Z3580 CPU and PowerVR G6430 GPU with 2GB RAM. In a somewhat unusual move, the Nokia N1 houses a whopping 32GB of internal storage. Initially this sounds impressive, until you realise it can't be expanded. Nonetheless, some manufactures have the gall to leave you with a lot less and no mi

Durga Puja Maps

Get the Official Map From Kolkata Police

WhatsApp add new features to Group Chat : Multiple Admins

The new Group Chat feature in WhatsApp lets you chat with up to 100 people at once. Previously it was only 50. It is a great way stay in touch with your family, friends and colleagues. Specially for people with larger number of peers, like students in a class or in a big office, it is now easy to add all the people as members of the group. In addition to the change in number of people you can add to a group, there are a few more changes : Every group has one or more admins. Only admins can add or remove participants. Previously you had only one admin for a group.  Now you can see the Received and Read receipt for all the members of the group, even if they have set privacy option. Other things you must know about Group Chats are: There is no limit to the number of groups you can create. Only admins can make other participants admins. If the last admin leaves the group, a new admin will be randomly assigned. You can always control your own participation in a Group Chat, by staying in or

Firefox dumps Google, signs with Yahoo as default search engine

Yahoo will replace Google as the default search engine on the Firefox web browser in the US, signalling Yahoo’s resolve to regain some of the ground that it has lost in the most lucrative part of the internet’s ad market. The five-year alliance announced on Wednesday will end a decade-old partnership in the US between Google and the Mozilla Foundation, which oversees the Firefox browser. The tensions between Google and Mozilla had been rising since Google’s introduction of the Chrome browser in 2008 began to undercut Firefox. Google’s contract with Mozilla expires at the end of November. Even though Chrome is now more widely used, Firefox still has a loyal audience that makes more than 100bn search requests annually worldwide. Besides dropping Google in the US, Mozilla is also shifting Firefox to the Baidu search engine in China and to Yandex in Russia. Firefox users still have the option to pull down a tab to pick Google and other search engines as their preferred way for looking up i