31 Mart 2013 Pazar

HW00_GYTE







//Write a program which calculates the perimeter and the area of a triangular. Your code will// take the edges of the triangular from the user (and nothing more) and outputs the perimete//r and the area.



/*
 * HW00_101044050                                                    
 * ------------------------------                                              
 * Created on 23.02.2013 by Sefa Sakarya                                      
 *                                                                            
 * Description                                                                
 * ------------------------------                                              
 * This implementation computes the perimeter and                          
 * area of a triangular.                                                  
 *                                                        
 * Notes                                                                      
 *  ------------------------------                                              
 * This is a demo files. Usually, the text with in the prolog is more verbose.
 *                           
 *
 * References                                                                  
 * ------------------------------                                              
 *  (If any)                 
 */
                   

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




int
main(void)
{
       double firstEdge, /*first edge length of triangular*/
       secondEdge,/*second edge length of triangular*/
       thirdEdge, /*third edge length of triangular*/
       perOfTriangular;/*perimeter of triangular*/
  
         double areaOfTriangular,/*area of triangular */
         halfOfPer;/*this variable is half of perimeter Triangular*/


        /*Get the edges lenght of triangular */
        printf("\n\nEnter the first edge of triangular  :");
        scanf("%lf",&firstEdge);
        printf("\nEnter the second edge of triangular :");
        scanf("%lf",&secondEdge);
        printf("\nEnter the third edge of triangular  :");
        scanf("%lf",&thirdEdge);


       /*Compute the perimeter of triangular and area of triangular */
       perOfTriangular = firstEdge + secondEdge + thirdEdge ;

        halfOfPer = perOfTriangular / 2 ;

        areaOfTriangular = sqrt(halfOfPer * ( halfOfPer - firstEdge ) * ( halfOfPer - secondEdge ) *
         ( halfOfPer - thirdEdge ));
/*Display the area of Triangular and perimeter of triangular */ printf("--------------------------------------"); printf("\n\nPerimeter of Triangular is %f .\n\n",perOfTriangular); printf("Area of Triangular is %f .",areaOfTriangular); printf("\n--------------------------------------"); printf("\nTerminating...");  


       
  
return 0;}

Hiç yorum yok:

Yorum Gönder