PF Assignment 2 (Updated)
PF Assignment 2 (Updated)
This assignment teach you how to install Dev C++ and run codes after installation.
2. Launch Dev-C++:
Mohabbat Ali
Program 2: Sum of Two Numbers
Mohabbat Ali
Program 4: Simple Interest Calculator
6. Following are programs expressed as English statement. Write only the programing
statements for actual program and their output.
In your program, substitute ??? with your own name. If necessary, adjust the positions and the
number of the stars to produce a rectangle.
int main()
{
//variable declaration
//executable statements
//return statement
}
a. Write C++ statements that include the header files iostream.
b. Write a C++ statement that allows you to use cin, cout, and endl
without the prefix std::.
c. Write C++ statements that declare the following variables: num1, num2,
num3, and average of type int.
d. Write C++ statements that store 125 into num1, 28 into num2, and
-25 into num3.
e. Write a C++ statement that stores the average of num1, num2, and
num3, into average.
Mohabbat Ali
f. Write C++ statements that output the values of num1, num2, num3, and
average.
g. Compile and run your program.
9. Repeat question 8 by declaring num1, num2, and num3, and average of type double.
Store 75.35 into num1, -35.56 into num2, and 15.76 into num3.
10. Consider the following C++ program in which the statements are in the incorrect order.
Rearrange the statements so that it prompts the user to input the radius of a circle and
outputs the area and circumference of the circle.
#include <iostream>
{
int main()
cout << "Enter the radius: ";
cin >> radius;
cout << endl;
double radius;
double area;
using namespace std;
return 0;
cout << "Area = " << area << endl;
area = PI * radius * radius;
circumference = 2 * PI * radius;
cout << "Circumference = " << circumference << endl;
const double PI = 3.14;
double circumference;
}
//include statement(s)
//using namespace statement
int main()
{
//variable declaration
//executable statements
//return statement
}
a. Write C++ statements that include the header files iostream and string.
b. Write a C++ statement that allows you to use cin, cout, and endl.
c. Write C++ statements that declare the following variables: name of type string and
studyHours of type double.
d. Write C++ statements that prompt and input a string into name and a double value into
studyHours.
Mohabbat Ali
e. Write a C++ statement that outputs the values of name and studyHours
with the appropriate text. For example, if the value of name is "Donald"
and the value of studyHours is 4.5, the output is:
Hello, Donald! on Saturday, you need to study 4.5 hours for the exam.
12. Write a program that prompts the user to input a decimal number and outputs the
number rounded to the nearest integer.
14. Submission:
Take output snap of each program and submit assignment document in groups before dealine
during lecture and also share on [email protected].
Mohabbat Ali