1) Write a shell script to print a set of numbers in reverse order. It should support the following requirements. The sc

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1) Write a shell script to print a set of numbers in reverse order. It should support the following requirements. The sc

Post by answerhappygod »

1) Write a shell script to print a set of numbers inreverse order. It should support the followingrequirements. The script should accept the input from the commandline. If you don’t inputany data, display an error message to execute the scriptcorrectly
a. Suppose the input number is n.b. Set reverse and single digit to 0 (i.e. rev=0, sd=0).c. The expression (n % 10) will give the single left-most digit,i.e., sd.d. To reverse the number, use this expression <rev * 10 +sd>.e. Decrease the input number (n) by 1.f. If n is greater than 0, go to step no. 3. Else, execute step no.7.h. Print the result.
Note: sd and rev are just variable names. However,you don’t have to use these steps as youcan devise your way of solving the problem.
Part B) For given numbers 1 to 10, displayonly odd numbers: 1,3,5,7,9Part C) For given numbers 1-15, display anynumber less than 5 and stop the loop.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply