Question: Write a program, with comments, to do the following: ( 2 8 + 2 = 3 0 ) a . Initialize a stringstr 1 .

Write a program, with comments, to do the following:(28+2=30) a.Initialize a stringstr1.str1should contain 5-10 characters. Printstr1 b.Ask the user to enter a positive integer between 1 and 26 and assign it to a variablen. Printn. Assume the user will enter an integer, but it may not be in the proper range. c.Check ifnis in the proper range. Ifnis in the proper range i.Create a variablexand assign it the value of thenth letter of the alphabet in lowercase. Printxwith a suitable message. HINT: You can use the built-inord()andchr()functions. ii.Find the number of occurrences ofxinstr1and print this value with a suitable message. otherwise print a message saying that the user entered an invalid input. d.Printstr1centered in a field of 20 characters, with * used as padding.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!