Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ General Guidelines: (for ALL of your programming assignments and labs) Use meaningful variable names. Use appropriate indentation. Use comments, especially for the header,

In C++

image text in transcribedimage text in transcribed

General Guidelines: (for ALL of your programming assignments and labs) Use meaningful variable names. Use appropriate indentation. Use comments, especially for the header, variables, and blocks of code. Please make sure that your submitted code has comments as points may be deducted for a lack of comments. Example Header: /* Author: Jane Doe (Jane. Doe@my.unt.edu) Date: Instructor: Description: A small description in your own words that describe what the program does. Any additional flags needed to allow the program to compile should also be placed here. Example Function Header: /* Function: Deposit Parameters: a double representing account balance and a double representing the deposit amount Return: a double representing account balance after the deposit Description: This function computes the account balance after a deposit. Loops If you wish to have a good working loop, there are three things that you have to always remember: initialization, whatever controls the loop and is checked by the Boolean expression, valid condition, the Boolean expression must correctly check the controlling variable, and change, the controlling variable must be changed so that the Boolean expression checks a new condition each time. If the condition does not change in the body of the loop, then the loop checks the same thing an infinite number of times and you will have an infinite loop. In other words, your program will never stop and you will have to terminate it manually (using CTRL-C). The syntax for a while loop is: while (Boolean_Expression) Statement 1; Statement 2; Statement Last; The part between { and } is called the body of the loop. In a while loop, the body of the loop may be executed 0 times. That means, if the Boolean expression evaluates to false right at the beginning, then the body of the loop will not get executed. Sometimes, you may want to execute the body of the loop at least once. In such a case, you should use a do-while loop. The syntax for a do-while loop is: do Statement 1; Statement 2; Statement Last; } while (Boolean_Expression); Pay particular attention to the semi-colon in the do-while that is not present in the while loop. A. while Loop In this program, you will count the number of alphabets, digits, whitespaces and special characters in a user entered string. Any character that is not an alphabet, a digit or a whitespace is a special character. To complete this program: Using a suitable message, get a string from the user. Note that the string may contain more than one word. Inside a while loop, test each character of the string one at a time. o Think about initialization, termination and update conditions for this loop. If it is an alphabet, a digit or a whitespace, update appropriate counters. If it is neither of them, update the counter for the special characters. Inform the user about all the counts

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions