0% found this document useful (0 votes)
6 views3 pages

PF Assignment

assignment

Uploaded by

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

PF Assignment

assignment

Uploaded by

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

2- Take input of two sides and calculate Area and Perimeter for a Quadrangle.

#include <iostream>
using namespace std;
void Perimetersq(int x, int y) {
cout << x * y;

}
void Perimeter(int a, int b) {
cout << a + a + b + b;

}
int main() {
int x = 0;
cout << " enter the value x to find the square ";
cin >> x;
cout << " enter the value of y to find the square";
int y = 0;
cin >> y;
cout << " value of area is ";
Perimetersq(x, y);
int a = 0;
cout << " Enter the value of a to find perimeter";
cin >> a;
cout << " Enter the value of b to find perimeter";
int b = 0;
cin >> y;
Perimeter(a, b);

3-Take input of three numbers, display largest using a function.

#include <iostream>
using namespace std;
int findLargest (int num1, int num2, int num3)
{
int largest = num1;
if (num2 > largest)
{
largest = num2;
}
if (num3 > largest)
{
largest = num3;
}
return largest;
}

int main()
{
int num1, num2, num3;

cout << "Enter three numbers: ";


cin >> num1 >> num2 >> num3;
int largest = findLargest(num1, num2, num3);

cout << "The largest number is: " << largest << endl;

return 0;
}

4- Take input of three numbers, display smallest using a function.

#include <iostream>
using namespace std;

int findSmallest(int num1, int num2, int num3)


{
int smallest = num1;
if (num2 < smallest)
{
smallest = num2;
}
if (num3 < smallest)
{
smallest = num3;
}
return smallest;
}
int main()
{
int num1, num2, num3;
cout << "Enter three numbers: ";
cin >> num1 >> num2 >> num3;

int smallest = findSmallest(num1, num2, num3);

cout << "The smallest number is: " << smallest << endl;
return 0;
}

5- Take input of Diameter. Write a function to calculate area & perimeter of a circle.

#include <iostream>
using namespace std;

double calculateArea(double diameter)


{
double radius = diameter / 2.0;
return 3.14159 * radius * radius;

double calculatePerimeter(double diameter)


{
return 3.14159 * diameter;

}
int main()
{
double diameter;
cout << "Enter the diameter of the circle: ";
cin >> diameter;

double area = calculateArea(diameter);


double perimeter = calculatePerimeter(diameter);

cout << "area of the circle: " << area << endl;
cout << "Perimeter of the circle: " << perimeter << endl;

return 0;

6- Calculate three surface areas of a cuboid and its volume.

You might also like