CBSE Class 11 Computer Science Functions In C++ Notes

Download CBSE Class 11 Computer Science Functions In C++ Notes in PDF format. All Revision notes for Class 11 Computer Science have been designed as per the latest syllabus and updated chapters given in your textbook for Computer Science in Class 11. Our teachers have designed these concept notes for the benefit of Class 11 students. You should use these chapter wise notes for revision on daily basis. These study notes can also be used for learning each chapter and its important and difficult topics or revision just before your exams to help you get better scores in upcoming examinations, You can also use Printable notes for Class 11 Computer Science for faster revision of difficult topics and get higher rank. After reading these notes also refer to MCQ questions for Class 11 Computer Science given on studiestoday

Revision Notes for Class 11 Computer Science Functions In C++

Class 11 Computer Science students should refer to the following concepts and notes for Functions In C++ in Class 11. These exam notes for Class 11 Computer Science will be very useful for upcoming class tests and examinations and help you to score good marks

Functions In C++ Notes Class 11 Computer Science

Functions in C++

Objectives :


• to analyze how modularity is implemented in a program at its lowest level.


  To appreciate the use and importance of function in C++


  to program different types of functions and implement them practically.


  To understand difference between User Define Function and Library function.


3.1: Why to use functions ?

Who likes unnecessary repetition of task ? No body in this world. Every body thinks of re usability these days in every aspect of life. What will you do if your cycle wheel rim breaks down on fine day? Do you will throw the whole cycle or sell the cycle as scrap? No exactly not because cycles are designed in such a way that each of its parts can be repaired or replaced. So you will get a new cycle rim from market and will get it fitted in your cycle! This design of cycle where each of its parts have its own unique functionality and could be reassembled together to form a complete cycle is known as


Modular approach of designing. Each of the cycles part can thought as a Module which serves some purpose in the whole cycle but is very essential for proper functioning of the cycle. The whole concept is nothing but based on “Divide and Rule philosophy”. A bigger system is divided into smaller components so that each of these smaller parts could handled easily and effectively. These smaller parts when integrated gives rise to the bigger system. 

Just think GOD has also created human beings as a modular entity ! We humans have a body which is integration of organ system and each of these organ system is again integration of some organs. So here organs are acting as modules. These modules (organs) could be taken care of individually when we often fall ill.

Can you rightly describe what is opposite word for modularity ? Any system which is not modular is known as monolithic (अखंड) or indivisible. A monolithic system does not have any parts or modules, from top to bottom it is one piece.

Software industry has also adopted the modular approach of design where a big software is divided into several modules. Each of the modules are designed for performing specialized task in the whole software. These modules interact with other modules of the system to carry out essential functionality of the whole system.

Each module during its course of execution repeats same type of task, so whenever the whole system requires a specific type of task , for which a particular module is responsible , it calls or invokes that module and the task is done. This calling of module to perform a certain action , can be done several number of times while the software as a whole executes.

Let us understand the above concept with the help of a real life example. Suppose our KVS is going to develop a centralized software for managing all Kvs across the country. While designing such a software KVS has to divide the whole operation of the software into three big modules called as : Admin , Academic and Accounts, each of these modules could be again broken down into many simple and small sub-modules like Admin Module can have Admission , Construction , Recruitment, etc. whereas the Academics can again have sub-modules like Student Registration, Examination , Results etc. 

class_11_Computer_science_concept_1

When the whole software is divided into modules as seen in the above case scenario then the following benefits could be harvested :

i) Each module can be tracked individually and separately without taking much care of other modules.

ii) A module is a reusable piece of program which could used again and again. Suppose that Navodaya Vidyalaya now wants to make a software like KVS then they can re-use the same modules of KVS with some changes (customization).

iii) If error is found in one module the functionality of that particular module and its associated modules would be disturbed, the whole software will not suffer. Thus errors can be tracked easily and debugged in much less time, because programmer will know which module is causing error, so he will debug that particular module only not the whole software (much like when you visit doctor suffering from common cold , the doctor does not checks your brain!)

iv) System up gradation (the process of changing from older system to newer one) becomes much easier because only those modules which needs up gradation will be dealt leaving other things as it is. So we see that modularization of a system gives us much independence and flexibility in terms of fast program development , easier debugging , and re-usability.

 

How Functions in C++ are related to program modules :

 

Just as a software is divided into modules , each modules into sub-modules , a sub-module is further divided into several functions. So we may call a function as a micro-level module of a bigger software.

 

A function in C++ :

 

- is smaller section of code of bigger module/program.

 

- is re-usable piece of code.

 

- is very specific in nature as it performs a specific task.

 

- is often called many times in a program.

 

Thus a C++ function have all the advantages which a module has in a software.

 

3.2: Types of function :

 

Functions in C++ are of two basic types :

 

a) User Defined : written by a programmer as per his/her requirement domain.

 

b) Library Function : already available with C++ compiler and stored as Library, from

 

where they can be called and used in any C++ program.

 

3.2.1 : User Defined Functions :

 

A user define function in C++ is always created by programmer according to his/her program requirements. Suppose, if some programmer is making software for school management then his list of user defined functions may have functions such as : getFee( ) , calcResult( ) , setExam( ) , all these functions will be used only in school management software not any where else, as they are specially tailored function for school management software.

 

Let us see the syntax to declare a user defined function :

 

Function Declaration :

 

<return type> function_name( <parameter list> ) ;

 

where :

 

return type := is the value which the function returns , if function does not returns any

 

value then we may write there void.

 

function_name := any valid C++ identifier name

 

parameter list := declaration of variables of different data types separated by comma these values are inputs passed from outside to the function.

 

The function declaration as per the syntax given above is also called as prototype declaration. In C++ it is compulsory to declare prototype of a function before defining and using it .

 

The parameter variable in the declaration are also called Formal parameters.

 

Function Definition :
 
While function definition described about the structure of a function , its inputs and output type , the definition of function actually implements the code of the function. While defining a function we add C++ code to its block as per requirement.
Syntax : <return type> function_name( <parameter list> )
{ … }
Example : Declare and define a function which finds the sum of two integers and returns it.
int getSum( int , int ); // declaration of a function
int getSum( int a , int b ) // definition of the function
{
int r = a+b;
return r;
}
 
The above function declaration has a return type as integer , because the function is meant to return a sum of two numbers. Two numbers to be added are passed to the function as input parameter. The parameter list is having two int separated by a comma ( , ) it is not compulsory to write a variable names of the parameters in declaration. A semicolon is terminating the declaration of function.
The definition of function is having code written within its scope where the sum is calculated over the passed parameters a and b and the result is returned using a keyword return. It is compulsory that the return data type must be same as that of the datatype of the variable returned using return statement.
 
Workout yourself :
 
Declare the prototype of a function which :
i) multiplies three integers and return the product
ii) checks whether a passed integer parameter is even or odd
iii) prints your name 20 times.
 
Consider the few more definition of functions related to various program :
Function 3.1 :
// function to check whether a given number is prime or not
int isPrime(int );
int isPrime(int num )
{
int count = 0;
for( int i = 1 ; i <= num ; i++)
if( num % I == 0)
count++;

 

if (count > 2 )

 

return 0 ; // more than two factors means it is not prime , hence a false value is returned

 

else

 

return 1 ; // exactly two factors i.e. 1 and num itself means num is prime , hence return a

 

// true value i.e. 1

 

}

 

In the above function if the passed parameter to the function i.e. num would be a prime it will have exactly two factors counted out in variable count and if not would have more than 2 factors. After we conduct a looping over the num to check its divisibility by every value from 1 to num we get count incremented whenever num is divisible by i (looping-variable ). So on the termination of loop the variable count stores the total number of times num gets divisible in the loop.
We check this count value to find whether it is more than two or not, if it is more than two it means num has more than two factors and hence it does not satisfies to be a prime , hence we return an

 

integer 0 to designate that it is not prime , other wise we return 1.
Instead of returning 1 and 0 from function you directly print using cout that num is prime or not, but then don't forget to change the return type of the function isPrime( ) to void.


Please click the link below to download pdf file for CBSE Class XI Computer Science Functions in C++ Concepts.

CBSE Class 11 Computer Science Functions In C++ Notes

We hope you liked the above notes for topic Functions In C++ which has been designed as per the latest syllabus for Class 11 Computer Science released by CBSE. Students of Class 11 should download and practice the above notes for Class 11 Computer Science regularly. All revision notes have been designed for Computer Science by referring to the most important topics which the students should learn to get better marks in examinations. Our team of expert teachers have referred to the NCERT book for Class 11 Computer Science to design the Computer Science Class 11 notes. After reading the notes which have been developed as per the latest books also refer to the NCERT solutions for Class 11 Computer Science provided by our teachers. We have also provided a lot of MCQ questions for Class 11 Computer Science in the notes so that you can learn the concepts and also solve questions relating to the topics. We have also provided a lot of Worksheets for Class 11 Computer Science which you can use to further make yourself stronger in Computer Science.

Where can I download latest CBSE Class 11 Computer Science Functions In C++ notes

You can download notes for Class 11 Computer Science Functions In C++ for latest academic session from StudiesToday.com

Are the revision notes available for Functions In C++ Class 11 Computer Science for the latest CBSE academic session

Yes, the notes issued for Class 11 Computer Science Functions In C++ have been made available here for latest CBSE session

Is there any charge for the Class 11 Computer Science Functions In C++ notes

There is no charge for the notes for CBSE Class 11 Computer Science Functions In C++, you can download everything free of charge

Which is the best online platform to find notes for Functions In C++ Class 11 Computer Science

www.studiestoday.com is the best website from which you can download latest notes for Functions In C++ Computer Science Class 11

Where can I find topic-wise notes for Class 11 Computer Science Functions In C++

Come to StudiesToday.com to get best quality topic wise notes for Class 11 Computer Science Functions In C++