Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ please include screenshots 2. Using a for-loop. Write a program that asks the user for a string 's' and a char' then counts how
c++
2. Using a for-loop. Write a program that asks the user for a string 's' and a char' then counts how many times 'e' appears in 's'. variable followed by a space, then output an asterisk (*) If the value of the for-loop counter variable Create a for-loop that cycles from 0 up to and including 20. On each iteration, output the counter is divisible by 2, an at symbol (@) if divisible by 3, and a dollar sign ($) if divisible by 4. The output of each iteration should be on a separate line. Note: Certain iterations may be divisible by more than one number. In such cases, you will have more than one symbol printed and separated by a space on that line. Sample output: $ 0 + @ $ 1 24 3 @ 4 5 6 @ 7 8 9 @ 10 * 11 12 * @ $ 13 14 15 @ 16 * $ 17 18 @ 19 20 * Hint: Make use of the modulus operator "%" (like we did in previous exercises) to determine if a number is divisible by 2, 3, or 4. For example, if I wanted to tell the user that a number is divisible by 2 then I could do something like: if (userInput % 2 = ) cout please include screenshots
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started