I Write a program with a loop that iterates as long as an int variable called num is less or equal to 50. Num must be initialized with a value of 1 and incremented by 1 with each iteration. Each iteration of the loop must print all appropriate sentences for that number according to the following 1. If num is odd, output: num is an odd number 2. If num is even, output: num is an even number output: num is divisible by 2 3. If num is divisible by 2, 4. If num is divisible by 5, output: num is divisible by 5 5. If num is divisible by 8, output: num is divisible by 8 6. If num is divisible by 11, output: num is divisible by 11 Please note that your class should be named FirstLoop.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

Homework 5

CMP 167: Programming Methods I Lehman College, City University of New York

Homework 5-1

I

Write a program with a loop that iterates as long as an int variable called num is less or equal to 50.

Num must be initialized with a value of 1 and incremented by 1 with each iteration.

Each iteration of the loop must print all appropriate sentences for that number according to the following

1. If num is odd,

output: num is an odd number

2. If num is even,

output: num is an even number output: num is divisible by 2

3. If num is divisible by 2,

4. If num is divisible by 5,

output: num is divisible by 5

5. If num is divisible by 8,

output: num is divisible by 8

6. If num is divisible by 11,

output: num is divisible by 11

Please note that your class should be named FirstLoop. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning