modifying code (use loop)

Thread Starter

TAKYMOUNIR

Joined Jun 23, 2008
352
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
 

Attachments

Thread Starter

TAKYMOUNIR

Joined Jun 23, 2008
352
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 );
}
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
 

WBahn

Joined Mar 31, 2012
29,976
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.
 
Top