modifying code (use loop)

Discussion in 'Programmer's Corner' started by TAKYMOUNIR, Oct 6, 2012.

  1. TAKYMOUNIR

    Thread Starter Active Member

    Jun 23, 2008
    351
    1
    i need to add loop in this code to be able to take a series prices of canadian price per liter and convert it to usa price per gallon so how can i do this loop to make output like this
    canadian price per liter us_price_per_gallon
    $xxx $xx
    $xxx $xx
    $xxx $xxx
    thanks
     
  2. panic mode

    Senior Member

    Oct 10, 2011
    1,319
    304
    printf("\n canadian_price_per_liter us_price_per_gallon");
    for (int i=1; i<= 3; i++){
    printf("\n $%g $%g \n", i*C_liter, i*D_gallon );
    }
     
    TAKYMOUNIR likes this.
  3. TAKYMOUNIR

    Thread Starter Active Member

    Jun 23, 2008
    351
    1
    thanks but i need to be able to enter many inputs and when i enter 0 or enter(exit) the progran get out from the loop
    thanks
     
  4. WBahn

    Moderator

    Mar 31, 2012
    17,716
    4,788
    Take the verbal description of what you need to do and recast it as a simple set of steps that need to be performed (i.e., pseudocode). Don't worry about how you will do it in a particular language, focus on the logic, first.
     
    TAKYMOUNIR likes this.
Loading...