Algoritma & Metode Skripsi

header ads

Turbo C + + program to calculate the area, perimeter and diagonal rectangle

In this article, I will discuss about creating a script to calculate the area, perimeter and diagonal of a rectangle by using Turbo C + +.


#include 
void main ()
{
    printf ("COUNTING RECTANGLE\nBy GALLIH FURMAN NUGRAHA\nTI-S1 C 2011\n\n\n");
    int p;
    int l;
    float luas;
    float keliling;
    float diagonal;
    int hitung;
printf ("to calculate the area of ​​select (1). \ n");
printf ("to calculate the circumference of select (2). \ n");
printf ("to calculate the diagonal choose (3). \ n \ n \ n");
printf ("enter the choice:");
    switch (hitung)
    {
        case 1 : printf ("\n\n");
                    printf ("calculate the area\n");
                    printf ("Panjang :");
                    scanf ("%d",&p);
                    printf ("Lebar :");
                    scanf ("%d",&l);
                    luas = p*l;
                    printf ("area of ​​rectangle : %f\n",luas);
                    break;
        case 2 : printf ("\n\n");
                    printf ("calculate the perimeter\n");
                    printf ("Panjang :");
                    scanf ("%d",&p);
                    printf ("Lebar :");
                    scanf ("%d",&l);
                    keliling = 2*p+2*l;
                    printf ("arround the rectangle : %f\n",keliling);
                    break;
        case 3 : printf ("\n\n");
                  printf ("calculate the diagonal\n");
                    printf ("Panjang :");
                    scanf ("%d",&p);
                    printf ("Lebar :");
                    scanf ("%d",&l);
                    diagonal = p*p+l*l;
                    printf ("diagonal rectangle : %f\n",diagonal);
                    break;
        default : printf ("The number you entered is incorrect");
    }
}



related posts : script C++ persegi panjang,
turbo C++ program persegi panjang,

Post a Comment

0 Comments