Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Other Programming (https://www.askmehelpdesk.com/forumdisplay.php?f=437)
-   -   Algorithm writing (https://www.askmehelpdesk.com/showthread.php?t=601084)

  • Oct 4, 2011, 11:45 PM
    maryam_nuha
    Algorithm writing
    Can you please tell me how to write this algorithm correctly?
    Question: A company is carrying out a survey by observing the traffic at road junction. Each time a car, bus or lorry passes by the road junction it was noted down. 10 000 vehicles were counted during the survey. Write an algorithm which inputs all 10 000 responses, outputs the number of cars, buses, and lorries that passes by the junction during the survey and outputs the number of vehicles that weren't cars, buses or lorries during the survey.

    Will this be correct?

    Cars=0

    Bus=0

    Lorry=0

    Other=0

    For counter= 1-10 000

    Input counter

    If counter=cars,then car=car+1

    If counter=bus, then bus=bus+1

    If counter=lorry,then lorry=lorry+1

    If counter=other,then other=other+1

    End if

    End if

    End if

    End if

    Next counter

    Output:Car, bus, lorry,other



    So, is my answer correct? If not, please correct it and explain please.

  • All times are GMT -7. The time now is 07:33 PM.