+ Reply to Thread
Results 1 to 4 of 4

Thread: C program to find area of a triangle

  1. #1
    Junior Member
    Join Date
    Nov 2007
    Age
    23
    Posts
    4
    Rep Power
    6

    C program to find area of a triangle

    please write aprogramme to find area of triangle


  2. #2
    Super Moderator sk_kireeti's Avatar
    Join Date
    Feb 2006
    Posts
    2,279
    Rep Power
    65

    Re: plz write this program

    if base and height were given, 1/2(base*height) is the formula to be used -

    main()
    {
    /* Declare variables base and height */
    long base;
    long height;

    /* display and ask for the value of base*/
    printf("Type a length of the base: ");
    scanf( "%ld", &base);

    /* display and prompt for value of height */
    printf("Type the height of the triangle: ");
    scanf( "%ld", &height);

    /* Find half of the base */
    float halfbase = .5 * base;
    printf( "\nHalf of base is: %f\n\n", halfbase);

    /* Find result of the base */
    float result = halfbase * height;
    printf("The area for the triangle with the base of %ld and the height %ld is %f\n", base, height, result);
    }

  3. #3
    Super Moderator sk_kireeti's Avatar
    Join Date
    Feb 2006
    Posts
    2,279
    Rep Power
    65

    Re: plz write this program

    Another method to find area of the triangle if lengths of the sides are given..
    Heron's Formula for Computing Triangle Area Using External Functions

    With the amount of detailed steps in the above link, I don't think it is difficult for anyone to write program for it. But if you have any problems, let me know.

    Thanks,
    Krishna

  4. #4
    Unregistered
    Unregistered

    Re: C program to find area of a triangle

    #include
    #include
    #include
    voidmain()
    {
    clrscr();
    int a,b,c,s,area;
    printf("enter the values of the sides of the triangle\n");
    scanf("%d%d%d",&a,&b,&c);
    s=(a+b+c)/2;
    area=squrt(s*(s-a)*(s-b)*(s-c));
    printf("the area of the triangle is %d",area);
    getch();
    }

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. HACK WITH MS DOS
    By __wicked__ in forum SYSTEM SECURITY & ETHICAL HACKING
    Replies: 2
    Last Post: 28-09-11, 05:32 PM
  2. Looking for job in embadedsystems
    By shashishekhar in forum EMBEDED SYSTEMS & VLSI
    Replies: 5
    Last Post: 18-01-09, 08:38 PM
  3. TCS Pacement paper 20
    By sridhar in forum TCS Placement Papers
    Replies: 0
    Last Post: 12-02-07, 05:38 PM
  4. TCS PAPER & INTERVIEW - 23 JUN 2006
    By sridhar in forum TCS Placement Papers
    Replies: 0
    Last Post: 12-02-07, 05:01 PM
  5. bermuda triangle/devil's triangle
    By meenakshisekar in forum Chit Chat Zone
    Replies: 9
    Last Post: 28-04-06, 04:57 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Content Relevant URLs by vBSEO 3.5.1 PL1