Project 10: Question

Rumman Ansari   Software Engineer   2026-02-15 12:14:59   24  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

Table of Content:

A snowball string is a sentence where each word is arranged in ascending order of their length and is also consecutive.

For example “I am the Lord” is a snowball string as:
Length of word ‘I’ is 1
Length of word ‘am’ is 2
Length of word ‘the’ is 3
Length of word ‘Lord’ is 4

The length of each word is one more than the previous word. Hence they are consecutive and in ascending order.

Write a program to enter any sentence and check if it is a snowball string or not. The words in the sentence may be separated by one or more spaces and terminated by ‘.’ or ‘?’ only. The program will generate appropriate error message for any other terminating character.

Test your program for the following data and some random data:

Example 1
INPUT: He may give bonus.
OUTPUT: IT IS A SNOWBALL STRING

Example 2
INPUT: Is the cold water frozen?
OUTPUT: IT IS A SNOWBALL STRING

Example 3
INPUT: Look before you leap.
OUTPUT: IT IS NOT A SNOWBALL STRING

Example 4
INPUT: The child is father of the man!
OUTPUT: INCORRECT TERMINATING CHARACTER. INVALID INPUT




Stay Ahead of the Curve! Check out these trending topics and sharpen your skills.