开发者

Simple Flowcharts

开发者 https://www.devze.com 2023-03-17 17:59 出处:网络
void main() { int numTickets; float discount; float total = 0.0; int numKids = 0; float ticketPrice = 19.00;
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消