Advertisements
Advertisements
प्रश्न
For some calculations, we want an algorithm that accepts only positive integers up to 100.
Accept_1 to 100_Algo
INPUT Number
IF (0 <= Number) AND (Number <= 100)
ACCEPT
Else
REJECT
- On what values will this algorithm fail?
- Can you improve the algorithm?
टीपा लिहा
Advertisements
उत्तर
If we enter 0 then this algorithm will fail.
Correct algorithm:
INPUT Number
IF (0 < Number) AND (Number <= 100)
ACCEPT
Else
REJECTshaalaa.com
Representation of Algorithms
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
