Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 5

PROBLEM07 - 10

PROBLEM07.CPP
• Factoring of integers. Write a program that asks the
user for an integer and then prints out all its factors.
For example, when the user enters 150, the program
should print
2
3
5
5
• Use a function that generates the factors of the
entered integer. Your program should allow the user to
repeat this calculation as often as the user wishes.
PROBLEM08.CPP
• Write a program for an Automated Teller
machine that dispenses money. The user
should enter the amount desired and the
machine dispenses this amount using the least
number of bills. The bills dispensed are 1000s,
500s,, 200s, 100s50s and 20s. Create a
function that computes the denomination of
the entered amount provided by the user.
PROBLEM09.CPP
• Write a function separate() that separates a
number into three parts: a sign(+ , -, or blank), a
whole number magnitude and a fractional part.
Develop a program that tests the separate()
function.
• Hint: Use the floor(x) function to get the nearest
value <= x
Sample Run:
Input a number? –3.44
RESULT: Sign: -
Integer Part: 3.0
Fractional Part: 0.44
PROBLEM10.CPP
• Given the coefficients a, b and c, the Quadratic Formula
provided below can be used to determine the roots (the values
of x1 and x2) of an equation of the form ax2+bx+c=0.

Write a C++ program that asks the user for the values of
coefficients a, b and c and write a function that computes the
roots of the equation.
Sample Run:
QUADRATIC FORMULA
-------------------------
Input coefficient a? 1 ◄┘
Input coefficient b? 7 ◄┘
Input coefficient c? 12 ◄┘
Roots of the equation are: x1 = -3 x2 = -4

You might also like