0% found this document useful (0 votes)
31 views6 pages

PF Assignment 2 (Updated)

This document provides instructions for an assignment on installing and using Dev C++ to write and run basic C++ programs. It includes 14 questions covering topics like: [1] installing Dev C++, [2] creating a new project, [3] writing and running simple programs to print output, calculate math problems, and take user input, and [4] rearranging code segments into the proper order. Students are to write the code for the programs, take screenshots of the output, and submit the completed assignment before the deadline.

Uploaded by

dureadeen01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views6 pages

PF Assignment 2 (Updated)

This document provides instructions for an assignment on installing and using Dev C++ to write and run basic C++ programs. It includes 14 questions covering topics like: [1] installing Dev C++, [2] creating a new project, [3] writing and running simple programs to print output, calculate math problems, and take user input, and [4] rearranging code segments into the proper order. Students are to write the code for the programs, take screenshots of the output, and submit the completed assignment before the deadline.

Uploaded by

dureadeen01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Introduction To Programming

ADP-ITM/ BBIS (Spring-24)


Assignment-2
Due date: March 24, 2024

This assignment teach you how to install Dev C++ and run codes after installation.

1. Download and Install Dev-C++: [5 marks]

 Go to the official Dev-C++ website at https://sourceforge.net/projects/orwelldevcpp/.


 Click on the "Download" button to download the latest version of Dev-C++.
 Run the installer and follow the on-screen instructions to install Dev-C++ on your
computer.

2. Launch Dev-C++:

 After installation, launch Dev-C++ by clicking on the desktop shortcut or finding it in


your program menu.

3. Create a New C++ Project: [5 marks]

 In Dev-C++, go to "File" > "New" > "Project..."


 Select "Console Application" and click "OK."

4. Write and Run Your C++ Code:

 Program 1: Hello World

Mohabbat Ali
 Program 2: Sum of Two Numbers

 Program 3: Calculate Area of a Rectangle

Mohabbat Ali
 Program 4: Simple Interest Calculator

 Program 5: Celsius to Fahrenheit Converter

5. Compile and Run:

 Save each program with a .cpp extension in your project directory.


 Click on "Execute" > "Compile & Run" to compile and execute your C++ code.
Mohabbat Ali
 The output will be displayed in the Output Console.

6. Following are programs expressed as English statement. Write only the programing
statements for actual program and their output.

1. The variable x starts with the value 10


2. The variable y starts with the value 2
3. The variable z starts with the value 4
4. Store the value of x times y in x
5. Store the value of y times z in y
5. Add x and z and store result in y
6. What is the value of y if output on screen

7. Write a program that produces the following output:

In your program, substitute ??? with your own name. If necessary, adjust the positions and the
number of the stars to produce a rectangle.

8. Consider the following program segment

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;
}

11. Consider the following program segment:

//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.

f. Compile and run your program.

12. Write a program that prompts the user to input a decimal number and outputs the
number rounded to the nearest integer.

13. Write a program that does the following:

a. Prompts the user to input five decimal numbers.


b. Prints the five decimal numbers.
c. Converts each decimal number to the nearest integer.
d. Adds the five integers.
e. Prints the sum and average of the five integers

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

You might also like