Computer Science, asked by prasannaprince21, 6 months ago

(a) Write a program to reverse a string
(b) Write a program that inputs a string with multiple words and then capitalizes the first

letter of each word. ​

Answers

Answered by maryamzafar915
2

Answer:

a

int main() { char s[100];

printf("Enter a string to reverse\n"); gets(s);

strrev(s);

printf("Reverse of the string: %s\n", s);

return 0; }

b

string = input('Enter line:')

length = len(string)

string2 = ''

for i in range(0, length):

if i == 0:

string2 += string[0].upper()

continue

elif string[i] == ' ':

string2 += string[i]

string2 += string[i+1].upper()

continue

elif string[i] != ' ':

if string2[i].upper() is True: # I feel like there is something wrong with this line

continue

else:

string2 += string[i]

print(string2)

Answered by jai696
2

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

s = input("enter string: ")

# (a) Write a program to reverse a string

print(s[::-1])

# write a program that inputs a string with multiple words and then

# capitalizes the first letter of each word.

print(" ".join(word[0].upper() + word[1:] for word in s.split()))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions