Assignment No. 3
CS201: Introduction to Programming
Total Marks: 20
Due Date:13 June, 2011
Please read the following instructions carefully before submitting your assignment:
It should be clear that your assignment will not get any credit if:
All types of plagiarism are strictly prohibited.
Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. If you will submit code in any other file format like .doc or .txt etc. you will get zero marks.
The objective of this assignment is to provide hands on experience of using
Problem Statement: Circle Area & Circumference Calculation
You are required to write a program which will calculate the area and circumference of the circle by declaring a class. You must declare a class named Circle whose only data member will be radius which should be declared as public. You need to define a macro for the value of PI which will be used while calculating the area of the circle.
1. Default Constructor which should initialize radius of the circle with value 0.
2. User Defined Constructor which takes class data member radius as its parameter.
It should be Display the area and circumference of the circle on the screen like the sample output.
Radius of the Circle = 0
Area of the Circle = 0
Circumference of the Circle is = 0
Radius of the Circle = 3.5
Area of the Circle = 38.465
Circumference of the Circle is = 21.98
Your Assignment solution must be submitted on or before June 13, 2011. You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. Assignment submitted in any other file format like .doc or .txt etc. you will get zero marks.
CS201 Assignment 3 Spring 2011
using namespace std;
cout "\nEnter the radius of circle: " ;
cin >> radius;
cout "\nThe radius of circle is: " radius endl;
fAreaCircle = (M_PI * radius) * radius;
fCircumferenceCircle = (2.0 * M_PI) * radius;
cout "The area of the circle is: " fAreaCircle endl;
cout "The circumference of the circle is: " fCircumferenceCircle endl;
But in in your provided solution, program is not asking for radius.
In instruction radius 3.5 is a sample output.
Sorry, Bhai Adnan Ayub ke solution mein execute kartay hoye thori si problem hai.
Correct solution is
using namespace std;
#define PI 3.14
radius = 0;
radius = r;
double Circle::calculateArea(double r)
double Circle::calculateCircum(double r)
cout "Radius of the Circle is " Circle::radius endl;
cout "Area of the Circle is " calculateArea(Circle::radius) endl;
cout "Circumference of the Circle is " calculateCircum(Circle::radius) endl endl;
which one is correct............ any one explain?
CS201 Assingment no 3 Solution Spring 2011
See the attached file please