Tuesday, July 31, 2012

Desigining Real World Network.

Ethernet is the most popular physical network architecture in use today. First conceived in the 1960s at the University of Hawaii as the ALOHA network. In 1972 Robert Metcalfe and David Boffs at Xerox PARC implemented the network architecture and signaling scheme and in 1975 they introduced the first Ethernet product. Ethernet is a bus or star bus based technology that uses baseband signaling and CSMA/CD to arbitrate network access.

  • Ethernet arbitrates access to the network with the CSMA/CD media access method.
  • Only one workstation can use the network at a time.
  • Workstations send signals (packets) across the network.
  • When a collision takes place, the stations transmitting the packets stop transmitting and wait a random period of time before retransmitting.
10Mbps Ethernet:
Four commonly used 10Mbps Ethernet cabling systems are:
  • 10Base5 or thicknet, which uses thick coaxial cable.
  • 10Base2 or thinnet, which uses thin coaxial cable.
  • 10BaseT, which uses UTP cable.
  • 10BaseFL, which uses optical fiber.
Specifications:
  • Maximum segment length                            500 m
  • Maximum taps                                             100
  • Maximum segments                                      5
  • Maximum segments with node                     3
  • Maximum distance between taps                  2.5 m
  • Maximum repeaters                                      4
  • Maximum overall length with repeater          2.5 kms
  • Maximum AUI drop cable length                  50m
  • Large size
  • High cost
  • Connection method
  • Very few advantages comparing today’s network but it is still reliable.
10Base2 (Thinnet) Ethernet:
Specifications:
  • Maximum segment length                            185 m
  • Maximum segments                                     5
  • Maximum segments with node                     3
  • Maximum repeaters                                     4
  • Maximum overall length with repeater        925 m
  • Maximum devices per segment                    30
Disadvantages of Thinnet:
  • High cost compared to UTP cable.
  • Bus configuration makes the network unreliable.
  • It was economical solution since longtime, so it is used in many existing installation
  • Maximum segment length                           100 m
  • Maximum segments                                    1024
  • Maximum segments with node                    1024
  • Maximum nodes per segment                      2
  • Maximum hubs in a chain                            4
  • Maximum nodes per network                     1024
Advantages:
  • UTP costs less and is more flexible than 10Base5 or 10Base2 cabling.
  • 10BaseT is easy to troubleshoot.
  • It is possible to isolate a device that is causing problems.
10BaseFL Ethernet:
Specifications:
  • Maximum segment length              2000 m
  • Maximum segments                       1024
  • Maximum segments with node      1024
  • Maximum nodes per segment        2
  • Maximum hubs in a chain             4
  • Maximum nodes per network       1024
100Mbps Ethernet:

For some applications, a 10Mbps data rate is not enough.
Two competing standards of 100Mbps:
  • 100VG-AnyLAN.
  • 100baseT Ethernet or Fast Ethernet.
100VG-AnyLAN has thefollowing advantages:
  • It is faster
  • It supports both Ethernet and Token Ring packets
  • It uses a demand priority access method
  • Hubs can filter individually addressed frames for enhanced privacy 

Sunday, July 29, 2012

Network Protocols For computer Networking

Protocols are the agreed upon ways in which computers exchange information.
Protocols that work together to provide a layer or layers of the Open System Interconnection model are known as protocol stack or suite.

Standard protocol stacks:
  •  The ISO/OSI protocol suite
  •  IBM System Network Architecture (SNA)
  •  Digital DECnet                    ,  AppleTalk
  •  Novell NetWare       , TCP/IP
A protocol is a set of basic steps that both parties must perform in the right way.

 For one computer to send a message to another computer, first computer must perform the following steps:
  1. Break the data into small section called packets
  2. Add addressing information to the packets identifying the destination computer
  3. Deliver the data to the network card for transmission over the network
The receiving computer must perform the same steps but in opposite order:
  1. Accept the data from the network adapter card.
  2. Remove the transmitting information that was added by the transmitting computer.
  3. Reassemble the packets of data into the original message.
 Networks primarily send and receive the small chunks of data called packets.

Packet structure: Packets have the following components:
  1. A source address specifying the sending computer.
  2. A destination address.
  3. Instructions that tell the computer how to pass the data along.
  4. Reassembly information for when the packet is part of a longer message.
  5. The data to be transmitted to the remote computer.
  6. Error-checking information to ensure that the data arrives intact.
 The components are combined into three sections:
  •  Header: Includes alert signal to indicate that the data is being transmitted, source and destination addresses and clock information to synchronize the transmission.
  •  Data: The actual data being sent. This can vary from 48 bytes to 4K.
  • Trailer: The contents of the trailer varies among network types, but it typically includes a CRC. CRC helps the network determine whether a packet has been damaged in transmission

Microsoft-Supplied Network Protocol:
  • NetBEUI
  • NWLink
  • TCP/IP
  • NetBEUI
NetBEUI: It stands for NetBIOS Extended User Interface. Microsoft included NetBEUI 3.0 with Windows NT. (Originally it is developed by IBM)

Advantages of NetBEUI:
  • High speed on small network
  • Ability to handle more than 254 sessions
  • Better performance over slow serial links than previous versions
  • Ease of implementation
  • Self-tuning features
  • Good error protection
  • Small memory overhead
Disadvantages of NetBEUI:
  • It cannot be routed between networks
  • Few tools for NetBEUI such as protocol analyzer
  • It offers very little cross-platform support
NWLink:
NWLink is Microsoft’s implementation of Novell’s IPX/SPX protocol stack, used in Novell NetWare.

Saturday, July 28, 2012

Network Adapters And The Theoretical Network

Network Adapter:

  • Network adapters perform all the functions required to communicate on a network.

  • They convert data from the form stored in the computer to the form transmitted or received on the cable and provide a physical connection to the network.
  • Fiber-optic Ethernet adapters convert the data from 8, 16 or 32 bit words to serial pulses of light.
  • Microwave network interfaces convert the computer data to serial radio waves.
  • Network adapters receive the data to be transmitted from the motherboard of your computer into a small amount of RAM called a buffer.
  • The data in the buffer is moved into a chip that calculates a checksum value for the chunk and add address information, which includes the address of the destination card and its own address.
  • Ethernet adapter addresses are permanently assigned when the adapter is made at the factory.
  • The network adapter must still convert the serial bits of data to the appropriate media in use on the network.
  • Some cards have more than one type of transceiver built in so you can use them with your choice of media.
  • While adapters transmit, they listen to the wire to make sure the data on the line matches the data being transmitted.
  • If another adapter has interrupted, the data being heard by the transmitting network adapter will not match the data being transmitted.
  • If then happens, the adapter ceases transmitting and transmits a solid on state instead, which indicates to all computers that it has detected a collision and that they should discard the current frame because has been corrupted.
  • The network adapter waits a random amount of time and then again attempts to transmit the frame.
    You have remember some condition for selecting an Adapter:
    • What type of network are you attaching to?
    • What type of media are you using?
    • What type of bus does your computer have?
    The Open System Interconnection Model attempts to define rules that apply to the following issues:
    • How network devices contact each other and if they have different languages, how they communicate with each other.
    • Methods by which a device on a network transmissions are received correctly and by the right recipient.
    • Methods to ensure that network transmissions are received correctly and by the right recipient.
    • How the physical transmission media are arranged and connected.
    • How to ensure that network devices maintain a proper rate of data flow.
    • How bits are represented on the network media.
    • The OSI model is nothing tangible; if is simply a conceptual framework.
    • The OSI model does not perform any functions in the communication process.
    • The OSI model simply defines which tasks need to be done and which protocols will handle those tasks, at each of the seven layers of the model.

    Friday, July 27, 2012

    Essential Network Components & Media for Networking.


    Media are what the message is transmitted over.

    Transmission media are divided into two categories:
    • Cable media: have a central conductor enclosed in a plastic jacket. Used for small LANs. Cable media normally transmit signals using the lower end of the electromagnetic spectrum. Ex- Coaxial, Twisted pair, Fiber-optic
    • Wireless media: employs the higher electromagnetic frequencies, such as radio wave, microwaves and infrared. It is used in mobile networks. They are prevalent in enterprise and global networks.
    Factors of Medium’s characteristics:
    • Cost: it should be weighed against the performance it provides and the available resources.
    • Installation: Some types of media can be installed with simple tools and little training; others require more training and knowledge and may be better left to professionals.
    • Bandwidth Capacity: In the world of networking, bandwidth is measured in terms of Mbps. A medium with high capacity has a high bandwidth. A high bandwidth normally increase the throughput and performance.
    • Node Capacity: Each network cabling system has a natural number of computers that can be attached to the network.
    •  Attenuation: Electromagnetic signals tend to be weaken during transmission. The phenomenon imposes limits on the distance a signal can travel through a medium without unacceptable degradation.
    • Electromagnetic Interference: EMI affects the signal that is sent through the transmission media. EMI is caused by outside electromagnetic waves affecting the desired signal. It is often referred to as noise.
    Characteristics of Cable Media

    Fiber-Optic Cable:
    • Fiber-optic cable transmits light signals rather than electrical signals.
    • Each fiber has an inner core of glass or plastic that conducts light.
    • The inner core is surrounded by cladding, a layer of glass that reflects the light back into the core.
    • Each fiber is surrounded by a plastic sheath.
    • The sheath can be either tight or loose.
    • A cable may contain a single fiber, but often fibers are bundled together in the center of the cable.
    • Optical fiber may be multimode or single mode.
    • Single mode fibers allow a single light path and are typically used with laser signaling.
    • Single mode fiber can allow greater bandwidth than multimode and is more expensive.
    • Multimode fibers use multiple light paths and use with LEDs.
    • Optical interface devices convert computer signals into light for transmission through the fiber.
    • Conversely, when light pulses come through the fiber, the optical interface converts them into computer signals.

    Thursday, July 26, 2012

    Signals Transmission In Network Communication

    Signal Transmission:
    Signaling is the way data is transmitted across the medium. It uses electrical energy to communicate.


    Two types of signaling:
    • Digital signaling 
    • Analog signaling


    Digital Signaling:
    Most computer networks use digital signaling.

    Encoding data in a digital signal is called encoding schemes.

    • Current-state encoding
    • State-transition encoding
    Current-state encoding:

    • In current-state encoding strategies, data is encoded by the presence or absence of a signal characteristics or state.
    • The signal is monitored periodically by network
    • State-transition encoding method use transitions in the signal to represent data.
    • Presence of transition represents a 1 and the absence of transition indicate a 0.


    State-transition encoding schemes:

    • Bipolar-Alternative Mark Inversion (AMI)
    • Non-Return-to-Zero (NRZ)Manchester
    • Differential Manchester
    • Biphase Space (FM-0)
    • Comparing Signaling Methods

    Advantages of digital signaling:
    • Fewer errors from noise and interference
    • Uses less expensive equipment
    Disadvantages of digital signaling:
    • Suffer from attenuation
    Advantages of Analog signaling:
    • Less attenuation than digital signal
    • Can be multiplexed to increase bandwidth

    Disadvantages of analog signaling:
    • More prone to errors from noise and interference

    Bit Synchronization:

    The coordination of signal measurement timing is called bit synchronization.

    Two major method of bit synchronization:

    • Asynchronous bit synchronization
    • Synchronous bit synchronization


    Asynchronous bit synchronization:


    Asynchronous bit synchronization
    Asynchronous communication requires that messages begin with a start bit so that the receiving device can synchronize its internal clock with the timing of the message.

    It is normally short and the end of the message is signaled by a stop bit.


    Synchronous bit synchronization:


    Synchronous communication requires that some kind of clocking mechanism be put into place to keep the clocks of the sender and receiver synchronized.


    Methods used for synchronous timing coordination:

    • Guaranteed state change
    • Separate clock signal
    • Oversampling

    Baseband and broadband Transmission


    Baseband: use the entire media bandwidth for a single channel. Commonly used for digital signaling. Most LANs use baseband signaling.

    Broadband: Provide the entire media bandwidth into multiple channels. Since each channel can carry a different analog signal, broadband networks support multiple simultaneous conversations over a single transmission medium.

    Broadband: Provide the entire media bandwidth into multiple channels. Since each channel can carry a different analog signal, broadband networks support multiple simultaneous conversations over a single transmission medium.

    Wednesday, July 25, 2012

    Different Kinds Of Network Topology In Computer Networks

    The way in which the connections are made is called the topology of the computer network. Now I am discussing about network topology, Network topology specifically refers to the physical layout of the network, especially the locations of the computers and how the cable is run between them.
    Four most common topologies are:
    • Bus                       
    •  Star
    •  Ring
    • Mesh
     Bus Topology:
    Bus topologies
     All the devices on a bus topology are connected by one single cable. When one computer sends a signal up the wire, all the computers on the network receive the information, but only one accepts the information. The rest regrets the message. One computer can send a message at a time. A computer must wait until the bus is free before it can transmit. When the signal reaches the end of the wire, it bounces back and travels back up the wire. When a signal echoes back and forth along an unterminated bus, it is called ringing. To stop the signals from ringing, attach terminators at either end of the segment. The terminators absorb the electrical energy and stop the reflection.
    Advantages and disadvantages of network topology:
    • advantage of network topology
    1. The bus is simple, reliable in small network, easy to use and understand
    2. Requires the least amount of cable to connect the computers and less expensive
    3.  Easy to extend the bus
    • Disadvantage of network topology
    1. Heavy network traffic can slow a bus considerably
    2. Each barrel connector weakens the electrical signal
    3.  Difficult to troubleshoot a bus
    Star Topology 
     All the cables run from the computers to a central location, where they are all connected by a device called a hub. Each computer on a star network communicates with a central hub that resends the message either to all the computers or only to the destination computers. Hub can be active or passive in the star network Active hub regenerates the electrical signal and sends it to all the computers connected to it. Passive hub does not amplify or regenerate signal and does not require electrical power to run. We can expand a star network by placing another star hub.

    Advantages:
    • Easy to modify and add new computers to a star net
    • Center of a star net is a good place to diagnose network faults
    • Single computer failure do not necessarily bring down the whole net
    • Several cable types can be used with the hub
    Disadvantages:
    • Central hub fails, the whole network fails to operate
    • Many star networks require a device at the central point to rebroadcast or switch network traffic.
    • Costs more for cabling in star net than bus.
    Ring Topology:
    Ring Topology 
     Each computer is connected to the next computer ,with the last one connected to the first. Every computer is connected to the next computer in the ring, and each retransmits what it receives from the previous computer. The message flow around the ring in one direction. Some ring networks do token passing. It passes around the ring until a computer wishes to send information to another computer. The computer adds an electronic address and data and sends it around the ring. Each computer in sequence receives the token and the information and passes them to the next until either the electronic address matches the address of the computer or the token returns to the origin. The receiving computer returns a message to the originator indicating that the message has been received. The sending computer then creates another token and place it on the network, allowing another station to capture the token and being transmitted.
    Advantages:
    • No computer can monopolize the network
    • The fair sharing of the network allows the net to degrade gracefully as more user are added. 
    Disadvantages:
    • Failure of one compute can affect the total network
    • Difficult to troubleshoot
    • Adding or removing Computers disrupts the network 
    Mesh Topology:
    Mesh Topology
     The mesh topology connects all devices (nodes) to each other for redundancy and fault tolerance. It is used in WANs to interconnect LANs and for mission critical networks like those used by banks and financial institutions. Implementing the mesh topology is expensive and difficult.
     Advantages:
    • Fault tolerance
    • Guaranteed communication channel capacity
    • Easy to troubleshoot
    Disadvantages:
    • Difficulty of installation and reconfiguration
    • Cost of maintaining redundant link

    Monday, July 23, 2012

    Introduction to Computer Networks(Part 1)

    Network and networking:
    A group of computers and other devices connected together is called network and the concept of connected computers sharing resources is called networking. The computers can be geographically located anywhere.

    LAN: Network in small geographical Area (Room, Building or a Campus) is called LAN (Local Area Network)

    MAN: Network in a City is call MAN (Metropolitan Area Network)

    WAN: Network spread geographically (Country or across Globe) is called WAN (Wide Area Network)


    Applications of Networks:
       Resource Sharing
    • Hardware (computing resources, disks, printers)
    • Software (application software)                
       Information Sharing
    • Easy accessibility from anywhere (files, databases)
    • Search Capability (WWW)
       Communication
    • Email
    • Message broadcast
     Remote computing
     Distributed processing (GRID Computing)
     Preserving information
     Protecting information

    There are three roles for computers in LAN:
    •  Clients- which use but do not provide network resources
    •  Peers- which both use and provide network resources
    •  Server- which provide network resources         
     Based on the roles of the computers attached, networks are divided into three types:
    •  server-based/client-server: containing clients and the servers that support them
    •  Peer /peer-to-peer: which have no servers and use the network to share resources among independent peers.
    •  Hybrid network: which is a client-server network that also has peers sharing resources.
    Server-based: Sever based networks are defined by the presence of servers on the network that provide security and administration of the network. Server-based networks divide processing tasks between clients and servers. Clients request services  and servers deliver them. Server computers are more powerful than client computers.

    Advantages:
    • strong central security
    • Central file storage
    • Ability to share expensive equipment
    • Optimized dedicated server
    • Less intrusive security
    • Free of users from the task of sharing
    • Easy manageability of large number of users
    Disadvantages:
    •  Expensive dedicated hardware
    • Expensive network OS software and client licenses
    •  A dedicated network administrator
    Peer Networks: Peer networks are defined by a lack of central control over the network. Users simply share disk space and resources Peer networks are organized into workgroups. Workgroups have very little security control.

    Advantages:
    • No extra investment in server hardware or software is required
    • Easy setup
    • No network administrator required
    • Ability of users to control resources sharing
    • No reliance on other computers for their operation
    • Lower cost for small networks
    Disadvantages:
    • Additional load on computers because of resource sharing
    • Inability of peers to handle as many network connections as servers
    • Lack of central organization
    • No central point of storage
    • Weak and intrusive security
    • Lack of central management

    Wednesday, July 18, 2012

    SOME EASY C/C++ CODE FOR IMPLEMENTING NUMERICAL METHODS(Part 2)

    MIDPOINT Method Code:

    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    float function(float x,float y)
    {
          float c;
           c=((2*y)/x);
           return c;
    }
            float yvalue(float y0,float f0,float h)
            {
            float d;
             d=(y0+((h*f0)/2));
             return d;
              }
              float xvalue(float x,float h)
              {
              float x1;
              x1=(x+(h/2));
              return x1;
               }
               int iteration(float a, float b, float h)
             {
            float n;
            n=fabs((b-a)/h);
            return n;
            }

    void main()
    {
           clrscr();
     float x0=0,y0=0,x=0,f0=0,x1=0,rvalue=0,lvalue=0,fvalue=0,now=0,h=0,y1=0,i=0,n=0;
       printf("ENTER 1st VALUE OF X:");
       scanf("%f",&x0);
       printf("\nENTER 1st VALUE OF Y:");
       scanf("%f",&y0);
       printf("\nWHICH VALUE OF X YOU WANT TO REACH:");
       scanf("%f",&x);
       printf("\nENTER STEP SIZE:");
       scanf("%f",&h);
       n=iteration(x,x0,h);
       if(x>x0)
       {

       for(i=0;i<n;i++)
       {
       x1=x0+h;
       f0=function(x0,y0);
       rvalue=yvalue(y0,f0,h);
       lvalue=xvalue(x0,h);
       fvalue=function(lvalue,rvalue);
       now=(fvalue*h);
       y1=(y0+now);
       printf("\n\nY(%.3f)=%.3f\n",x1,y1);
       y0=y1;
       x0=x1;
       }
      }
    else
      {
    for(i=0;i<n;i++)
    {
    x1=x0-h;
    f0=function(x0,y0);
    rvalue=yvalue(y0,f0,h);
    lvalue=xvalue(x0,h);
    fvalue=function(lvalue,rvalue);
    now=(fvalue*h);
    y1=(y0+now);
    printf("\n\nY(%.3f)=%.3f\n",x1,y1);
    y0=y1;
    x0=x1;
      }
      }
    getch();
    }


    #include<stdio.h>
    #include<conio.h>
    #include<math.h>

    float function(float x)
    {
    float c;
    c=((x*x)-(4*x)+3);
    return c;
     }
    float derivative(float x)
    {
    float d;
    d=((2*x)-4);
    return d;
     }
    float point(float x0,float f0, float f1)
    {
    float x1;
    x1=(x0-(f0/f1));
    return x1;
     }
    float error(float x0,float x1)
    {
    float value;
    value=(fabs((x0-x1)/x0)*100);
    return value;
     }
    void main()
    {
    clrscr();
    int i;
    float x0=0,x1=0,f0=0,f1=0,e=0;
    printf("ENTER INITIAL VALUE:");
    scanf("%f",&x0);
    f0=function(x0);
    if(f0==0)
    {
    printf("root is =%.4f",x0);
    }
    else
    {

    for(i=0;i<=6;i++)
    {
    printf("x0=%.4f",x0);
    f0=function(x0);
    printf("\nf0=%.4f",f0);
    f1=derivative(x0);
    printf("\nf1=%.4f",f1);
    x1=point(x0,f0,f1);
    printf("\nx1=%.4f",x1);
    e=error(x0,x1);
    printf("\nERROR=%.4f",e);
    x0=x1;
    printf("\n---------------------------------------------\n");
    }
    }
    getch();
      }


    #include<stdio.h>
    #include<conio.h>
    #include<math.h>

    float function(float x)
        {
         float c;
         c=((x*x)-(4*x)+3);
        return c;
        }
        float point(float x1,float x2,float f1, float f2)
       {
        float x3;
        x3=(x2-((f1*(x2-x1))/(f2-f1)));
        return x3;
        }
        float error(float x1,float x2)
       {
       float value;
       value=(fabs((x2-x1)/x2)*100);
       return value;
       }
    void main()
    {
    clrscr();
    int i;
    float x1=0,x2=0,x3=0,f1=0,f2=0,f3=0,e=0,p=0,q=0;
    printf("ENTER 1st INITIAL VALUE:");
    scanf("%f",&p);
    printf("ENTER 2nd INITIAL VALUE:");
    scanf("%f",&q);
    f1=function(p);
    f2=function(q);
    if(f1*f2==0)
    {
    if(f1==0)
    {
    printf("ROOT IS=%.3f",p);
    }
    else
    {
    printf("ROOT IS=%.3f",q);
    }
    }
    else
    {
    if(p>q)
    {
    x1=p;
    x2=q;
    }
    else
    {
    x1=q;
    x2=p;
      }
    for(i=0;i<=6;i++)
    {
    printf("x1=%.4f",x1);
    f1=function(x1);
    printf(" f1=%.4f",f1);
    printf("\nx2=%.4f",x2);
    f2=function(x2);
    printf(" f2=%.4f",f2);
    x3=point(x1,x2,f1,f2);
    printf("\nx3=%.4f",x3);
    f3=function(x3);
    printf(" f3=%.4f",f3);
    e=error(x1,x2);
    printf("\n ERROR=%.4f",e);
    x1=x2;
    x2=x3;
    printf("\n---------------------------------------------\n");
    }
    }
    getch();
    }

    Thursday, July 12, 2012

    SOME EASY C/C++ CODE FOR IMPLEMENTING NUMERICAL METHODS

    Bisection Method Code:

    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    float function(float x)
    {
    float c;
    c=((x*x)-(4*x)+3);
    return c;
    }
    float middle(float a,float b)
    {
    float d;
    d=((a+b)/2);
    return d;
    }
    float error(float x1,float x2)
    {
    float value;
    value=(fabs(((x2-x1)/x2)*100));
    return value;
    }

    void main()
    {
    clrscr();
    float x1=0,x2=0,f1=0,f2=0,E,x0=0,f0=0,p,q,root;
    int i;

    printf("ENTER 1st VALUE:");
    scanf("%f",&x1);

    printf("\nENTER 2nd VALUE:");
    scanf("%f",&x2);

    f1=function(x1);
    printf("\n\nf1=%.4f",f1);
    f2=function(x2);
    printf("\n\nf2=%.4f",f2);

    if(f1*f2==0)
    {
    if(f1==0)
    {
    printf("\n\nROOT IS X1=%.4f",x1);
    }
    else
    {
    printf("\n\nROOT IS X2=%.4f",x2);
    }
    }

    else if(f1*f2<0)
    {
    for(i=0;i<=6;i++)
    {
    printf("\nx1=%.3f",x1);
    printf("\ x2=%.3f",x2);
    f1=function(x1);
    printf("\nf(x1)=%.3f",f1);
    f2=function(x2);
    printf(" f(x2)=%.3f",f2);
    E=error(x1,x2);
    printf("\nERROR=%.2f",E);
    x0=middle(x1,x2);
    printf("\nX0=%.4f",x0);
    f0=function(x0);
    printf(" f(x0)=%.4f",f0);
    p=(f1*f0);
    q=(f2*f0);

    if(p<0&&q>0)
    {
    x2=x0;
    printf("\n--------------------------------------\n");
    }
    else
    {
    x1=x0;
    printf("\n--------------------------------------\n");
    }
    }
    }

    else
    {
    printf ("\n\nANSWER DOESNOT EXISTS BETWEEN THIS LIMIT");
    }
    getch();
    }

    False Position Method:

    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    float function(float x)
    {
    float c;
    c=((x*x)-(4*x)+3);
    return c;
    }
    float middle(float a,float b,float g,float h)
    {
    float d;
    d=(a+(g*(b-a)/(g-h)));
    return d;
    }
    float error(float x1,float x2)
    {
    float value;
    value=(fabs((x2-x1)/x2));
    return value;
    }

    void main()
    {
    clrscr();
    float x1=0,x2=0,f1=0,f2=0,E,x0=0,f0=0,p,q,root;
    int i;

    printf("ENTER 1st VALUE:");
    scanf("%f",&x1);

    printf("\nENTER 2nd VALUE:");
    scanf("%f",&x2);

    f1=function(x1);
    printf("\n\nf1=%.4f",f1);
    f2=function(x2);
    printf("\n\nf2=%.4f",f2);

    if(f1*f2==0)
    {
    if(f1==0)
    {
    printf("\n\nROOT IS X1=%.4f",x1);
    }
    else
    {
    printf("\n\nROOT IS X2=%.4f",x2);
    }
    }
    else if(f1*f2<0)
    {
    for(i=0;i<=6;i++)
    { printf("\nx1=%.3f",x1);
    printf("\ x2=%.3f",x2);
    f1=function(x1);
    printf("\nf(x1)=%.3f",f1);
    f2=function(x2);
    printf(" f(x2)=%.3f",f2);
    E=error(x1,x2);
    printf("\nERROR=%.2f",E);
    x0=middle(x1,x2,f1,f2);
    printf("\nX0=%.4f",x0);
    f0=function(x0);
    printf(" f(x0)=%.4f",f0);
    p=(f1*f0);
    q=(f2*f0);

    if(p<0&&q>0)
    {
    x2=x0;
    printf("\n--------------------------------------\n");
    }
    else
    {
    x1=x0;
    printf("\n--------------------------------------\n");
    }
    }
    }
    else { printf ("\n\nANSWER DOESNOT EXISTS BETWEEN THIS LIMIT"); }
    getch();
    }

    HUNS Method Code:

    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    float function(float x,float y)
    {
    float c;
    c=((2*y)/x);
    return c;
    }
    float euler(float y0,float m, float h )
    {
    float d;
    d=(y0+(h*m));
    return d;
    }
    float next(float y0,float h, float m, float n)
    {
    float e;
    e=(y0+((h*(m+n))/2));
    return e;
    }
    int iteration(float a, float b, float h)
    {
    float n;
    n=((a-b)/h);
    return n;
    }

    void main()
    {
    clrscr();
    float x0=0,y0=0,x1=0,yeuler=0,yreal=0,h=0,m1=0,m2=0,n=0,xfinal=0;
    int i;

    printf("ENTER 1st VALUE OF X:");
    scanf("%f",&x0);

    printf("\nENTER 2nd VALUE OF Y:");
    scanf("%f",&y0);

    printf("\nENTER STEP SIZE H:");
    scanf("%f",&h);

    printf("\nWHICH VALUE OF X YOU WANT TO REACH:");
    scanf("%f",&xfinal);
    n=iteration(xfinal,x0,h);
    for(i=1;i<=n;i++)
    {

    m1=function(x0,y0);
    printf("\n\nm1=%.4f",m1);
    x1=x0+h;
    yeuler=euler(y0,m1,h);
    printf("\n\ny(%.3f)=%.4f",x1,yeuler);
    m2=function(x1,yeuler);
    printf("\n\nm2=%.4f",m2);
    yreal=next(y0,h,m1,m2);
    printf("\n\ny(%.3f)=%.4f",x1,yreal);
    x0=x1;
    y0=yreal;
    printf("\n-----------------------------------\n");
    }
    getch();
    }