[go: up one dir, main page]

0% found this document useful (0 votes)
20 views34 pages

PPS Unit-4 Combined Notes

Uploaded by

Green Panther
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)
20 views34 pages

PPS Unit-4 Combined Notes

Uploaded by

Green Panther
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/ 34

Programming for Problem Solving (BCS 101/BCS 202)

UNIT-4 : Function & Recursion.

100 % Guaranteed highest marks pakke.


Most important 4 questions.
These questions come in AKTU exam every year.
Part-1

Today’s Target
By Pragya Rajvanshi
Clear exam with good marks.
Complete unit in oneshot. B.Tech M.tech (C.S.E.)
2 years + experience
Last moment content.
Ques1) What is function? What is function declaration, function call and function
definition (2020-19, 2018-17,2017-18, 2016-17 , 2014-15)

WHAT IS FUNCTION?
A function is a self-contained subprogram that is meant to do some
specific, well-defined task.
 A program consists of one or more functions.
If a program has only one function then it must be the main function.

ADVANTAGES
 Debugging of the code would be easier .
 To improve the readability of code.
 Reduces the size of the code.
Ques1) What is function? What is function declaration, function call and function
definition (2020-19, 2018-17,2017-18, 2016-17 , 2014-15)

WHAT IS FUNCTION DEFINITION?


The function definition consists of the whole description and code of a
function.
return_type func_name ( type1 argl, type2 arg2,…… )
{
local variables declarations;
statement;
return(expression) ;
}

.
Ques1) What is function? What is function declaration, function call and function
definition (2020-19, 2018-17,2017-18, 2016-17 , 2014-15)

WHAT IS FUNCTION CALLING?


The function definition describes what a function can do, but to actually
use it in the program the function should be called somewhere. A
function is called by simply writing its name followed by the argument list
inside the parentheses.
func_name(arg1, arg2, arg3 ...)

.
Ques1) What is function? What is function declaration, function call and function
definition (2020-19, 2018-17,2017-18, 2016-17 , 2014-15)
WHAT IS FUNCTION DECLARATION/ FUNCTION PROTOTYPE?
 The calling function needs information about the called function.
If definition of the called function placed before the calling function, then
declaration is not needed.
it informs the compiler about the following three things.

1Name of the function


2Number and type of arguments received by the function.
3Type of value returned by the function.

The general syntax of a function declaration is-


return_type func_name(type1 arg1, type2 arg2, .......);

ACTUAL ARGUMENT - Those used in function call.


FORMAL ARGUMENT - Those used in function definition.
Ques2)What do mean by passing parameters? Discuss various types of
parameter passing mechanism in C with example(2020-21, 2019-18,2018-19, 2017-18,
2016-17, 2015-16, 2012-13,2011-12)

Parameter Passing Methods: While calling a function, there are two ways
in which arguments can be passed to a function –

 CALL BY VALUE:
This method copies the actual argument values to formal argument. In this
case, changes made to the formal argument have no effect on actual
argument.

 CALL BY REFERENCE:
This method copies the actual argument address to formal argument. In this
case, changes made to the formal argument have effect on actual argument.
CALL BY VALUE
CALL BY REFERENCE
Ques3) Define recursion. Write a program to find out factorial of a number
using recursion.

Recursion: The function that calls itself again and again is known as recursive
function. In recursion the calling function and the called function are same.
void main()
{ ... .. ...
recurse();
}
void recurse()
{ ... .. ...
recurse();
}
Ques4) Define recursion. Write a program to find sum of Fibonacci series
using recursion (0 1 1 2 3 5 8 . . . ). (2021-22, 2019-20, 2018-192017-18,
2016-17, 2014-15)
Or
Write a program to print of Fibonacci series
using recursion (0 1 1 2 3 5 8 . . . ).
Write a program to print of Fibonacci series
using recursion (0 1 1 2 3 5 8 . . . ).
Write a program to print sum of Fibonacci series
using recursion (0 1 1 2 3 5 8 . . . ).
Download Gateway Classes Application
From Google Play store

Link in video Description


Programming for Problem Solving (BCS 101/BCS 202)

UNIT-4 : SORTING AND SEARCHING.

100 % Guaranteed highest marks pakke.


Most important 2 questions.
These questions come in AKTU exam every year.
Part-2

Today’s Target
By Pragya Rajvanshi
Clear exam with good marks.
Complete unit in oneshot. B.Tech M.tech (C.S.E.)
2 years + experience
Last moment content.
Ques5)what is searching ? Difference between linear search and binary search
or
Write a program of linear search and binary search(2016-17,2018-19,2019-20)

SEARCHING:
Searching is a process of locating a particular element present in a given set of
elements. The element may be a record, a table, or a file.
There are two basic techniques available for searching.
1) Linear Search (Sequential Search)
2) Binary Search
LINEAR SEARCH PROGRAM
BINARYSEARCH PROGRAM
Ques2) Implement sorting technique using bubble sort on the following
sequence:
34, 78, 12, (2018-19, 2019-20,2021-22)
Download Gateway Classes Application
From Google Play store

Link in video Description

You might also like