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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
