0% found this document useful (0 votes)
11 views8 pages

CSI Pract5 6

The document outlines practical exercises for C++ programming, focusing on function creation and overloading. Practical No. 5 involves writing a function to multiply two numbers, while Practical No. 6 covers calculating the area of a rectangle and circle using overloaded functions. It includes example programs and explanations of key concepts such as function overloading and polymorphism.
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)
11 views8 pages

CSI Pract5 6

The document outlines practical exercises for C++ programming, focusing on function creation and overloading. Practical No. 5 involves writing a function to multiply two numbers, while Practical No. 6 covers calculating the area of a rectangle and circle using overloaded functions. It includes example programs and explanations of key concepts such as function overloading and polymorphism.
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/ 8

STES’

Sinhgad College of Arts, Science and


Commerce (Jr.College)
Ambegaon (Bk)
Bifocal Computer Science
Mrs. Taraka Ghamande
(Teacher & Moderator In Computer Science)
CSI –Chapter 3

C++ Programming
Practical No. 5
Aim
: To study the function and related terms in C++.

Problem statement
Write a function in c++ to multiply the two
numbers and display the product using function.
Enter the program and verify the execution of
the same on the computer.
Program
// program to multiply two numbers using a function
#include <iostream.h>
// declaring a function
int multi(int a, int b)
{
return (a * b);
}

void main()
{
int p;
// calling the function and storing the returned value in p
p= multi(12, 8);
cout << “12*8= " << p << endl;
}
Practical No. 6
Aim
: To study the overloading of functions in C++.

Problem statement
•Write a program in c++ to calculate the area of
rectangle and circle using the overloading of
functions.
•Enter the program and verify the execution of
the same on the computer.
Function Overloading
•Function overloading is a feature in C++ where two or
more functions can have the same name but
different parameters.

•Function overloading can be considered as


an example of polymorphism feature in C++.

•Functions are called as per the parameters specified in


the function.
Program
#include<iostream.h>
#include<conio.h>
#define pi 3.14
void area(int); //circle
void area(int, int); //rectangle
void main()
{
int l, b, r;
clrscr();
cout << "Enter Radious of the Circle:";
cin>>r;
area(r);
cout << "Enter Sides of the Rectangle:";
cin >> l>>b;
area(l, b);
}
Program
void area(int a)
{
cout << "Area of Circle:" << pi * a*a;
}
void area(int l1, int b1)
{
cout << "Area of rectangle:" << l1*b1;
}

You might also like