Showing posts with label Class Notes: C Programming. Show all posts
Showing posts with label Class Notes: C Programming. Show all posts

What is recursion?




Recursion : Recursion is a special case where a function calls itself. A very simple example of recursion is presented below,



What is nesting of functions?




Nesting of functions : In C, each function can contain one or more than one function in it. There is no limit as to how deeply functions can be nested. Consider the following example,


What is function prototype?




Prototype : The declaration of a function is known as function prototype. The function prototype is coded in the following format,



What are parameters in functions?




Function Parameter: Function parameters are variables of a function that we can use to send data to the function. Parameters are declared as follows:



How to declare a function in C or C Plus Plus?



Function declaration : The program or a function that called a function is referred to as the calling function or calling program. The calling program should declare any function that is to be used later in the program. This is known as the function declaration. 




Explain or Discuss function call.




Function call : In order to use functions user need to invoke it at a required place in the program. This is known as the function call. A function can be called by simply using the function name followed by a list of actual parameters, if any, enclosed in parentheses.


Explain or Describe function definition.

Function Definition: 

The function definition is an independent program module that is specially written to implement to the requirements of the function. A function definition, also known as function implementation shall include the following elements

What are the elements of user defined functions?

User defined functions

Functions are blocks of codes to perform specific tasks and return the result. However it is not mandatory for a function return anything and also a function is not limited to performing one task only. User defined functions are basic building blocks of a program and can be found in the basic structure of C program.

Functions can be classified into two categories, namely, library functions and user-defined functions. The functions which are developed by user at the time of writing a program are called user defined functions. Thus, user defined functions are functions developed by user.


What is multi-function program?

Multifunction program : A function is a self-contained block of code that performs a particular task. Once a function has been designed and packed, it can be treated as a ‘black box’ that takes some data from the main program and returns a value. Thus a program, which has been written using a number of functions, is treated as a multi-function program.

What are the advantages of user defined functions?

User defined functions

Functions are blocks of codes to perform specific tasks and return the result. However it is not mandatory for a function return anything and also a function is not limited to performing one task only. User defined functions are basic building blocks of a program and can be found in the basic structure of C program.

Functions can be classified into two categories, namely, library functions and user-defined functions. The functions which are developed by user at the time of writing a program are called user defined functions. Thus, user defined functions are functions developed by user.

What are user defined functions? What are the advantages of user defined function.

User defined functions

Functions are blocks of codes to perform specific tasks and return the result. However it is not mandatory for a function return anything and also a function is not limited to performing one task only. User defined functions are basic building blocks of a program and can be found in the basic structure of C program.

Functions can be classified into two categories, namely, library functions and user-defined functions. The functions which are developed by user at the time of writing a program are called user defined functions. Thus, user defined functions are functions developed by user.

3 Differences between counter and sentinel controlled loops. Counter controlled loop VS Sentinel controlled loop

The differences between the counter and sentinel controlled loops are as follows.

3 Differences between entry and exit controlled loops with examples. Entry controlled loops VS Exit controlled loops

The differences between the entry and exit controlled loops are as follows.

Compare among the three loops. FOR loop VS WHILE loop VS DO....WHILE

Comparison among the three loop: 

The comparison among the three types of loops for loop, while loop and do....while loop is given below.

Suggested Reading:
  1. What are the entry controlled and exist controlled loops?
  2. What are the counter controlled and sentinel controlled loops?

What are the entry controlled and exit controlled loops?

Loops in computer programs refers to a block of code that is executed over and over based on meeting some criteria or condition. However a loop can be broke or exited from inside the loop also. The block of code in a loop keeps on executing again and again unless it meets a certain condition or being exited explicitly from inside the loop. Thus, if not well-conditioned a loop might keep on running causing the program to fail ultimately.

Depending on the position of the control statement in the loop, loops can be of two types
  1. Entry Controlled 
  2. Exit Controlled
Beside this, loops can be categorized in to two other categories called counter controlled loops and sentinel controlled loops based on the nature of the control variables and the kind of value assigned to them. You can lean more about counter and sentinel controlled loops here and learn more about the differences between counter and sentinel controlled loops here.

Write down the steps of looping process.

Steps of looping process: A looping process, in general, would include the following four steps.

What are the counter controlled and sentinel controlled loops?

Based on the nature of the control variables and the kind of value assigned to, the loops may be classified into two general categories; counter controlled and sentinel controlled loops.

What is loop

Loop

A loop is a particular area of a program where some executable statements are written which gets execution by testing one or more conditions. So, in looping, a sequence of statements is executed until some conditions for termination are satisfied.

A program loop therefore consists of two segments; the body of the loop and the control statement.

What are the static arrays and dynamic arrays

Static arrays : The process of allocating memory at compile time is known as static memory allocation and the arrays that receives static memory allocation are called static arrays. This approach works fine as long as user know that what the data requirements are.

Write down the initialization of two dimensional array

Initialization of two dimensional array : Like the one dimensional arrays, two dimensional arrays may be initialized by following their declaration with a list of initial values enclosed in braces. For example,