Selasa, 29 September 2015

Program C - Tek. Kompilasi

#include
#define square(x) x*x
#define PI 3.141592

main()
{
    float area;     /* Circle area.   */
    float radius;   /* Circle radius. */

    printf("Give me the radius => ");
    scanf("%f",&radius);

    area = PI * square(radius);

    printf("The area of a circle with a radius of %f\n",radius);
    printf("is %f square units.",area);
}


====================== End ========================

Daftar token untuk C 
klik


==================================================
#include
main()
{
    float mph;              /* Speed in miles per hour. */
    float fpm = 5280.0;     /* Feet per mile.           */
    float sph = 3600.0;     /* Seconds per hour.        */
    float fps;              /* Feet per Second.         */

    printf("Enter speed in miles/hour => ");
    scanf("%f",&mph);
    printf("\n");
    fps = mph * fpm / sph;
    printf("The speed in feet/second is %f\n",fps);
}

=========================End=======================

#include
main()
{
    float R1;      /* Resistor 1.            */
    float R2;      /* Resistor 2.            */
    float REQ;     /* Equivalent resistance. */

    printf("Enter resistor 1 value => ");
    scanf("%f",&R1);
    printf("Enter resistor 2 value => ");
    scanf("%f",&R2);
    printf("\n");
    REQ = (R1 * R2) / (R1 + R2);
    printf("The equivalant resistance is %f\n",REQ);
}




===================END===================================
#include
#include
main()
{
    float amount;      /* Dollars to invest.    */
    float interest;    /* Yearly interest rate. */
    float years;       /* Number of years.      */
    float total;       /* Total accumulation.   */

    printf("Enter amount to invest => ");
    scanf("%f",&amount);
    printf("Enter yearly interest rate => ");
    scanf("%f",&interest);
    printf("Enter the number of years => ");
    scanf("%f",&years);
    printf("\n");
    interest /= 100.0;
    total = amount * pow((1.0 + interest),years);
    printf("The total accumulation is %f\n",total);
}

=============================End=========================











Tidak ada komentar:

Posting Komentar

Pengikut

Arsip Blog