write a program to enter a string like"sunil is a good boy
and seeking for a job" not more than 10 characters including
space in one line,rest characters should b in other line.if
the next line starts from in between the previous word,then
print whole word to next line.
Answer / Rahul Chaudhary
Here's an example in Python that illustrates the desired functionality:
input_string = "sunil is a good boy and seeking for a job"
words = input_string.split() # Split the string by whitespace
output_string = ""
for word in words:
if len(output_string) == 0 or (len(output_string.split("n")[-1]) + len(word) + 1 > 10): # Check if current line is full or there's space to add the word
output_string += f"{word}n" # If there's space, add the word with a newline
else: # If the current line is full, print the whole line and start a new one
output_string += f"{output_string.split('n')[-1]} " # Print the last word of the previous line without the newline character
output_string += f"n{word}" # Add the next word with a newline
| Is This Answer Correct ? | 0 Yes | 0 No |
Write a program in c++ to read two floating point numbers and find their sum and average.
What are the three parts of a simple empty class?
1. Define a class.
why we are declare the function in the abstract class even though we are declaring it in Derived class?
What is the difference between pass by reference and pass by value?
what is the size of an empty class
What is property in oops?
string is a class or data type in java?
can inline function declare in private part of class?
What is multilevel inheritance?
What is multilevel inheritance in oop?
What are the features of oop?