Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 3: Function Write a function named triangle that accepts an integer parameter representing a size in characters, and prints to the console a right-aligned

Exercise 3:

Function Write a function named triangle that accepts an integer parameter representing a size in characters, and prints to the console a right-aligned right triangle figure whose non-hypotenuse sides are that length. For example, the call of triangle(5); should print the following output: * ** *** **** ***** You may assume that the value passed for the size is at least 1. Exercise 4: Function Write a function named word_count that accepts a string as its parameter and returns the number of words in the string. A word is a sequence of one or more non-space characters (any character other than ' '). For example, the call of word_count("hello, how are you?") should return 4. Constraints: Do not use any data structures such as arrays to help you solve this problem. Do not use the String function explode on this problem. But you can declare as many simple variables like Integer, String, etc. as you like.

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions