Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions