Jump to content

Let Us GCC/Code 1.1

From Wikibooks, open books for an open world
(Redirected from Let Us GCC/Example1)

Old code

[edit | edit source]
/* Calculation of simple interest */
/* Author gekay Date: 25/05/2004 */
main( )
{
    int p, n ;
    float r, si ;

    p = 1000 ;
    n = 3 ;
    r = 8.5 ;

    /* formula for simple interest */
    si = p * n * r / 100 ;

    printf ( "%f" , si ) ;
}

New code

[edit | edit source]
/* Calculation of simple interest */
/* Author gekay Date: 25/05/2004 */
/* Editor GReaperEx Date: 19/7/2015 */

#include <stdio.h>

int main(void)
{
    const int p = 1000;
    const int n=3;
    const float r = 8.5f

    /* formula for simple interest */
    float si = p*n*r/100;

    printf("%f", si);
    
    return 0;
}