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

Itc Lab Report: Ojective

This lab report discusses functions in C++. The objective was to understand pre-defined and user-defined functions, and functions that return values. The introduction defines functions as segments of code that perform specific tasks, including library functions and user-defined functions. The procedure explains the syntax for defining functions, including the type, name, parameters, and statements. The conclusion states that defining functions makes code reusable and saves time. The post lab includes code to define a function that calculates the mean and standard deviation of 5 numbers.
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)
65 views5 pages

Itc Lab Report: Ojective

This lab report discusses functions in C++. The objective was to understand pre-defined and user-defined functions, and functions that return values. The introduction defines functions as segments of code that perform specific tasks, including library functions and user-defined functions. The procedure explains the syntax for defining functions, including the type, name, parameters, and statements. The conclusion states that defining functions makes code reusable and saves time. The post lab includes code to define a function that calculates the mean and standard deviation of 5 numbers.
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/ 5

ITC LAB REPORT

EXPERIMENT NO : 8

ROLL NO: 19L-1367

SECTION: EE-2 , LAB: 2A

Ojective:

In this lab ,we


 Understand how to use pre-defined functions
 Understand how to define your own functions
 To get familiar with value returning functions

Introduction:
C++ is widely used among the programmers or
developers and the engineers. It contains the important parts
including variable, data types, etc. It is very useful for writing our
own program by creating our own logics and its used in all types of
things like games , applications, operating systems etc.It is very
helpful for us.

In programming, function refers to a segment that


groups code to perform a specific task. Depending on whether a
function is predefined or created by programmer; there are two types of
function: Library Function, User-defined Function. Library functions are
the built-in function in C++ programming.Programmer can use library
function by invoking function directly; they don't need to write it
themselves. C++ allows programmer to define their own function. A
user-defined function groups code to perform a specific task and that
group of code is given a name(identifier). When the function is invoked
from any part of program, it all executes the codes defined in the body
of function.

Procedure:
In C++, a function is a group of statements that is given a name, and which can
be called from some point of the program. The most common syntax to define a
function is:

type name ( parameter1, parameter2, ...) { statements }

Where:
- type is the type of the value returned by the function.
- name is the identifier by which the function can be called.
- parameters (as many as needed): Each parameter consists of a type followed
by an identifier, with each parameter being separated from the next by a
comma. Each parameter looks very much like a regular variable declaration
(for example: int x), and in fact acts within the function as a regular variable
which is local to the function. The purpose of parameters is to allow passing
arguments to the function from the location where it is called from.
- statements is the function's body. It is a block of statements surrounded by
braces { } that specify what the function actually does.
Issues:

I have faced the issue that i did not that how to get the
value in updated form, then i use the refrence(&) iin this way i
solved my issue.

Conclusion:

My conclusion after doing the experiment no 7 is


that we can also a program by using functions, if we make a fuction
in a program then use it several times in our code then it is very
helpful and we can use it by simply calling the fuction that we
already created.

Applications:

Today we use c++ in every field of computers and


making amd developing different type of programs ,games
,operating systems.it is very useful for making a program of our
requirments and use for our own pupose and save our time.it is also
used to design graphics ,games , developing applications.
POST LAB:
CODE:
#include <iostream>

#include <cmath>

using namespace std;

double function (double mean, double stdv)

int n1,n2,n3,n4,n5;

cout<<"enter the 5 numbers : "<<endl;

cin>>n1>>n2>>n3>>n4>>n5;

mean=n1+n2+n3+n4+n5/5;

stdv = sqrt((pow(n1-mean,2)) + (pow(n2-mean,2)) +

(pow(n3-mean,2)) + (pow(n4-mean,2) +(pow(n5-mean,2)))/ 5);

int main()

double mean;

double stdv;

function(mean,stdv);

cout<<" The average of 5 numbers is :"<<mean<<endl;

cout<<"The standard deviation of 5 numbers is:"<< stdv;

return 0;

OUTPUT:

You might also like