0% found this document useful (0 votes)
4 views7 pages

Lab 4 Lab 4

lab 4 OOP Preston Uni

Uploaded by

ah8951512
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)
4 views7 pages

Lab 4 Lab 4

lab 4 OOP Preston Uni

Uploaded by

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

PRESTON UNI VERSITY ISLAMABAD

Obiect-Oriented Programming Lab Report Submitted by:


Name: Waheed Ur Rehman

Reg no: 1422-123004

Submitted to:

Mrs. Saira Kishwar Abbas

Lab # 4
Section:BSCS(E)

Submission Date : 12/22/2023


LAB #4
FUNCTIONS
Program No#1:
Write C++ program that prompts the user for the radius of a circle, then calls inline function circleArea to
calculate the area of that circle.
Program No#2:
Write a function called swap() that interchanges two int values passed to it by the calling program.
(Note that this function swaps the values of the variables in the calling program, not those in the function). You’ll
need to decide how to pass the arguments. Create a main() program to exercise the function.
Program No#3:
Write a program that asks for a number and a power.
Write a recursive function that takes the number to the power. For example, if the number is 2 and the power is 4,
the functio will return 16.
Program No#4:
Write a function that, when you call it, display a message telling how many times it has been called:” I have been
called 3 times”, for instance. Write a main() program that calls this function at least 10 times. Try implementing this
function in two different ways. First, use a global variable to store the count. Second, use a local static variable.
Which is more appropriate? Why can’t you use a local variable?
Program No#5:
The formula for converting a temperature from Fahrenheit to Celsius is {C=5/9 (F-32)}

F is the function named Celsius that accepts a Fahrenheit temperature as an argument. The function should return
the temperature, converted to Celsius. Demonstrate the function by calling it in a loop that displays a table of the
Fahrenheit temperature 0 through 20 and their Celsius equivalents.

You might also like