void main()
{
int numTickets;
float discount;
float total = 0.0;
int numKids = 0;
float ticketPrice = 19.00;
printf("Enter number of tickets: ");
scanf("%d", &numTickets);
if (numTickets > 10)
{
discount = 0.15;
}
else
{
discoun开发者_如何学Ct = 0.0;
}
printf("Enter number of children: ");
scanf("%d", &numKids);
total = numKids*ticketPrice/2.0 + (numTickets – numKids)*ticketPrice;
total = total*(1.0 – discount);
printf("Total = %.2f \n", total);
}
basically, im helping my cousin study and one of the questions is to draw a flowchart for that. the problem is iv forgotten everything i ever knew about flowcharts! Is there a standard for the variable declerations at the top? I can make up the rest of it actually, just not sure how to start em anymore!
Regular assignments (like your variable initialisations) should appear in a normal rectangle (like those in http://upload.wikimedia.org/wikipedia/commons/d/d6/FlowchartExample.png).
Remember that IO (like your printf
/scanf
statements) should be in parallelograms, and conditional branches in diamonds.
The very basic rules:
- variable declarations (and in general blocks of code) go into rectangular boxes
- conditions (also of iterations) go into diamonds
- outputs go into parallelograms
Wikipedia article can be useful.
精彩评论