how to apply phythagoras theorem to caculate hypotenuse without math.h without header

This is a discussion on how to apply phythagoras theorem to caculate hypotenuse without math.h without header within the C++ Programming forums, part of the General Programming Boards category; any 1 has solution for it:, In the triangle Pythagoras theorem is used to find out the length of any ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    10

    Unhappy how to apply phythagoras theorem to caculate hypotenuse without math.h without header

    any 1 has solution for it:, In the triangle Pythagoras theorem is used to find out the length of any in known side
    If the base is 4 cm and height is 7cm find out the hypotenuse by using the Pythagoras

    (Hypotenuse) 2 = (base) 2+ (perpendicular )2


    , i need C++ code of it without header file of <math.h> , need to put only conio.h ,iostream.h header file only,

    have done this code:
    Code:
    #include<conio.h>
    #include<iostream.h>
    #include<math.h>
    void main()
    {
    clrscr();
    int base,perp,hyp;
    base=4,perp=7;
    base=base*base;
    perp=perp*perp;
    hyp=sqrt(base+perp);
    cout<<hyp;
    getch();
    }
    but i hv to do this solution without math.h header file, then how can i find square root ? any alternate method to solve it without math.h header file please help
    Last edited by amerjamil; 10-29-2010 at 09:28 AM.

  2. #2
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,649

  3. #3
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,649
    OK, now for the next thing to read: << !! Posting Code? Read this First !! >>

  4. #4

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    10
    rags@ i have read it.. now please try to help me

  6. #6
    Registered User
    Join Date
    Oct 2010
    Posts
    10
    fronty@ can u please tell me for 65 to calculate square root

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,431
    amerjamil, if you are really lost, then go for a naive but easy to understand and implement solution for integers: increment starting from 0, and square the number. Eventually, the square will be equal to (or greater than) your target number, thus you know that the current number (or previous number) is the square root.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Replies: 5
    Last Post: 06-01-2006, 04:37 PM
  3. Obtaining source & destination IP,details of ICMP Header & each of field of it ???
    By cromologic in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-29-2006, 02:49 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21