0% found this document useful (0 votes)
30 views5 pages

Lab REPORT 09

The document contains 4 C++ programs with code and output: 1. A program that calculates the area of a circle using a function. 2. A program that checks if a number is even or odd using a boolean function. 3. A program that calculates power of a number using a function. 4. A program that swaps two numbers using a function.

Uploaded by

Haseeb Ahmed
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)
30 views5 pages

Lab REPORT 09

The document contains 4 C++ programs with code and output: 1. A program that calculates the area of a circle using a function. 2. A program that checks if a number is even or odd using a boolean function. 3. A program that calculates power of a number using a function. 4. A program that swaps two numbers using a function.

Uploaded by

Haseeb Ahmed
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/ 5

NUST COLLEGE OF ELECTRICAL AND MECHANICAL ENGINEERING

LAB REPORT # 8
NAME: Abdul Wahab
DEGREE: 42
SYNDICATE:C
DEPARTMENT: Mechanical Engineering
COURSE: CS-114 Fundamentals of Programming
PROGRAM # 1
***CODE:
#include<iostream>
using namespace std;
float area(float rad)
{
float result=1;
result = rad * 3.141592653589793238;
cout << "The Area of Circle = ";
return result;
}
float main()
{
float a ;
cout << "Enter Radius of Circle : ";
cin >> a;
cout << area(a);
return 0.0 ;
}

***OUTPUT:

PROGRAM # 2
***CODE:
#include<iostream>
using namespace std;
bool oetest(int num)
{

int result = 1;
cout << "The Required bol. type is : ";
if (num % 2 == 0)
{
cout << "1" << endl;
}
if (num % 2 == 1)
{
cout << "0" << endl;
}

return 0;
}
int main()
{
int a;
cout << "Enter Any Number : ";
cin >> a;
cout << oetest(a);
return 0;
}
***OUTPUT:

PROGRAM # 3
***CODE:
#include<iostream>
using namespace std;
int power(int base, int exp)
{
int result=1;
for (int a=0; a < exp; a++)
{
result = result * base;
}
cout << "The Result = ";
return result;
}
int main()
{
int a, b;
cout << "Enter Base of Number : ";
cin >> a;
cout << "Enter Exponent of Number : ";
cin >> b;

cout << power(a,b);


return 0;
}

***OUTPUT:

PROGRAM # 4
***CODE:
#include<iostream>
using namespace std;
int swap(int a, int b)
{
cout << "The First Number is = " << b << endl;
cout << "The Second Number is = " << a << endl;
return 0;
}
int main()
{
int a, b;
cout << "Enter First Number : ";
cin >> a;
cout << "Enter Second Number : ";
cin >> b;
cout << swap(a, b);
return 0;
}
***OUTPUT:

You might also like