Ask Experts Questions for FREE Help !
Ask
    maryam_nuha's Avatar
    maryam_nuha Posts: 6, Reputation: 1
    New Member
     
    #1

    Oct 4, 2011, 11:45 PM
    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.

Check out some similar questions!

Program and algorithm [ 1 Answers ]

HI ,, CUD ANYONE GIVE ME A WORKING ALGORITHM AND PROGRAM IN C ABOUT LCM AND MODE , MEDIAN ,,AND HCF,, IT SHULD WORK IN LINUX OS TOO.. THANK..U..:o :)

Structure of the algorithm [ 2 Answers ]

Write a set of instructions using while loop and if... else Selection structures to sort the pile of cards according to the Symbols they display and write an appropriate message for each Card, for example 'shaded circle' or 'unshaded square'. Each Message should be on a new line. The...

Using random_shuffle from <algorithm> [ 1 Answers ]

I can't seem to get 'random_shuffle' from <algorithm> to work correctly. I have defined a class 'aCard' which has data members 'aRank' and 'aSuit'. Then define a vector of aCards called 'deck'. I initialize the deck with 'initDeck()' and try to shuffle the deck with 'shuffleDeck()'. Just for...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.