What is function definition? (OR) what is user defined function? (OR)
Write syntax of user defined function?

1 Answer

Answer :

Function Definition : The program module that is written to achieve a specific task is called function definition.
Syntax : type function-name(parameter list) // function header.
 {
declaration of variables;
 body of function; // Function body
 return statement;
 }
Where
type : return type can be int ,float,double,void etc. This is the type of the value that the function is expected to
return. If the function is not returning any value, then we need to specify the return types as void.
function-name : is the name of the function.
parameter-list : Parameter list declares the variables that will receive the data sent by the calling program.
Example of User Defined Function :
#include<stdio.h>
void add(); //function declaration/prototype
void main()
{
 add(); //Function call
}
void add() // function definition
{
 int a,b,c;
 printf(“Enter the values of a and b”);
 scanf(“%d%d”,&a,&b);
 c=a+b;
 printf(“%d”,c);
}

Related questions

Description : what is function? Write types of function with example?

Last Answer : Function: Function means, a large program can be divided into a series of individual related programs called modules. These modules are called functions. A function is a program segment that carries out ... efficiency of program. 4 : Function sharing : A function can be shared by many programmers.

Description : What is a function? Write advantages of function?

Last Answer : Function: Function means, a large program can be divided into a series of individual related programs called modules. These modules are called functions. A function is a program segment that carries ... efficiency of program. 4 : Function sharing : A function can be shared by many programmers

Description : What is the macro function?

Last Answer : Macro Substitution : They are two types of macro substitution. 1 : Macro substitution without arguments. 2 : Macro substitution with arguments. 1 : Macro substitution without arguments : It is a process to ... varn like the formal parameters in a function definition. Ex : #define PROD(x) (x*x)

Description : What is return statement in function?

Last Answer : Return Statement : The return statement may or may not send back any values to the calling function(main program). Syntax : return; // does not return any value or return(exp); // the ... function can return some values other than int type, then we must specify the data type to be return.

Description : What are the function variables? (OR) What are the local and global variables?

Last Answer : FUNCTION VARIABLES : They are two types of variables. 1 : Local Variable. 2 : Global Variable. 1 : Local Variable : The local variables are defined within the body of the function or block. These ... variables m' and n' are defined outside the main() function. Hence they are global variables.

Description : What are the function parameters?

Last Answer : PARAMETERS : parameters provides the data communication between the calling function and called function. They are two types of parametes 1 : Actual parameters. 2 : Formal parameters. 1 : Actual Parameters : These ... . . } Where a, b are the Actual Parameters x, y are the Formal Parameters

Description : What is calling function? (OR) what is function call?

Last Answer : Function Call : The function can be called by simply using the function name. Syntax : function-name(); function-name(parameters); return value = function-name(parameters); Ex : add(); // function ... ,b); // function with arguments. c=fun(a,b); // function with arguments and return values

Description : How to Decleration of function?

Last Answer : Function Declaration (Function Prototype) : Like variable, all functions in a C program must be declared, before they are invoked. The declaration of each function should end with semicolon. Ths is ... : Parameter list declares the variables that will receive the data sent by the calling program.

Description : Write a C program addition of two matrices?

Last Answer : #include #include void main() { int a[25][25],b[25][25],c[25][25],i,j,m,n; clrscr(); printf("enter the rows and colums of two matrics:\n"); scanf("%d%d",&m,&n); printf("\nenter the elements of A matrics"); for(i=0;i

Description : Write a C program multiplication of two matrices?

Last Answer : // Write a C program Multiplication of Two Matrices. #include #include void main() { int a[25][25],b[25][25],c[25][25],i,j,m,n,k,r,s; clrscr(); printf("enter the rows and colums of A matrics:\n"); ... B matrics:\n"); scanf("%d%d",&r,&s); printf("\nenter the elements of A matrics"); for(i=0;i

Description : What is an Array? Write advantages of arrays?

Last Answer : An array is a collection of similar data items. All the data items of an array are stored in continuous memory locations in RAM. The elements of an array are of same data type and each item can be accessed using the same name.

Description : Write categeory of functions ?

Last Answer : CATEGORY OF FUNCTIONS : A function, depending on whether arguments are present or not and whether a value is returned or not. The following are the function prototypes. 1 : Functions with no ... : Functions with Parameters and no Return Values. 4 : Functions with Parameters and Return Values.

Description : Write types of functions?

Last Answer : The functions can be classified into two categories. 1 : Built in Functions (OR) Library Functions 2 : User-defined Functions. 1 : Built-in Functions (OR) Library Functions : The standard C ... increase efficiency of program. 4 : Function sharing : A function can be shared by many programmers.

Description : What is call by value and call by reference?

Last Answer : PASSING PARAMETERS TO FUNCTIONS : The called function receives the information from the calling function through the parameters. The variables used while invoking the calling function are called actual parameters and the variables used in the ... *b) { int temp; temp=*a; *a=*b; *b=temp; }

Description : Explain category of functions with examples?

Last Answer : CATEGORY OF FUNCTIONS : A function, depending on whether arguments are present or not and whether a value is returned or not. The following are the function prototypes. 1 : Functions with no Parameters and no Return Values. 2 : ... (); } int sum(int a,int b) { int c; c=a+b; return c; }

Description : How to initialization of array with example?

Last Answer : Initilization of Array : assigning the required information to a variable before processing is called initialization.we can initialize the individual elements of an array. Array elements can be initialized at the time of declaration. Syntax : ... M','P','U','T','E','R'}; char b[] = COMPUTER ;

Description : What is call by reference? (OR) what is pass by reference?

Last Answer : Pass by reference (OR) Call by Reference : In pass by reference, a function is called with addresses of actual parameters. In the function header, the formal parameters receive the addresses of actual parameters. Now the formal parameters do ... a,int *b) { int temp; temp=*a; *a=*b; *b=temp; }

Description : What is call by value? (OR) what is pass by value?

Last Answer : Pass by value (OR) Call by value : When a function is called with actual parameters, the values of actual parameters are copied into formal parameters. If the values of the formal parametes changes in the function, the values of ... void swap(int a,int b) { int temp; temp=a; a=b; b=temp; }

Description : Write syntax and use of pow ()function of header file.

Last Answer : pow()- compute the power of a input value Syntax: double pow (double x, double y);

Description : A variable is defined within a block in a body of a function. Which of the following are true? A) It is visible throughout the function. B) It is visible from the point of definition to the end ... visible from the point of definition to the end of the block. D) It is visible throughout the block.

Last Answer : D) It is visible throughout the block.

Description : Describe Define How arrays can be passed to a user defined function?

Last Answer : One thing to note is that you cannot pass the entire array to a function. Instead, you pass to it a pointer that will point to the array first element in memory. To do this, you indicate the name of the array without the brackets.

Description : Explain User defined function with example.

Last Answer : Functions are basic building blocks in a program. It can be predefined/ library functions or user defined functions. Predefined functions are those which are already available in C library. User defined functions are those which are ... value is: %d",a); } void main() { myFunc(10); getch() }

Description : Write a program to input name and salary of employee and throw user defined exception if entered salary is negative. 

Last Answer : import java.io.*; class NegativeSalaryException extends Exception { public NegativeSalaryException (String str) { super(str); } } public class S1 { public static void main(String[] args) ...  catch (NegativeSalaryException a) {  System.out.println(a);  } } }

Description : What is syntax for dropping a procedure and a function .Are these operations possible?

Last Answer : Drop Procedure procedure_name Drop Function function_name

Description : If we define putchar function in putchar :. char -> IO () syntax than character input as an argument andreturns a. Useful value b. Get output c. Getno output d. None of these

Last Answer : c. Getno output

Description : Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error. Does c++ support multilevel and multiple inheritance?

Last Answer : Yes.

Description : State the syntax & use of strlen ( ) & strcat ( ) function.

Last Answer : strlen( ): calculates the length of the string Syntax: strlen(s1); strcat():concatenates two strings Syntax: strcat(s1,s2)

Description : Describe syntax and use of defining member function outside class. Give one example.

Last Answer : Member function that is declared inside a class has to be defined separately outside the class. These member functions associate a membership identify label in the header. This label tells the ... ) A member function can call another member function directly, without using the dot operator. 

Description : Give syntax and use of fclose ( ) function.

Last Answer : Syntax:  int fclose(FILE* stream); Use: This function is used to close a file stream. The data that is buffered but not written is flushed to the OS and all unread buffered data is discarded.

Description : Write syntax to define a derived class

Last Answer : Syntax: class derived_class_name : visibility_mode/access_specifier base_class_name { class body };

Description : Write the syntax of switch case statement. 

Last Answer : switch(variable) { case value1: statements break; case value2: statements; break; . . . default: statements; break; }

Description : Define pointer. Write syntax for pointer declaration.

Last Answer : Definition: A pointer is a variable that stores memory address of another variable which is of similar data type.  Declaration: datatype *pointer_variable_name; 

Description : Write syntax and example of : 1) drawRect() 2)drawOval()

Last Answer : 1)drawRect() : drawRect () method display an outlined rectangle. Syntax: void drawRect(int top,int left, int width,int height) The upper-left corner of the Rectangle is at top and left. The ... and height the following program draws several ellipses and circle. Example: g.drawOval(10,10,50,50);

Description : Write the syntax of try-catch-finally blocks.

Last Answer : try{ //Statements to be monitored for any exception } catch(ThrowableInstance1 obj) { //Statements to execute if this type of exception occurs } catch(ThrowableInstance2 obj2) { //Statements }finally{ //Statements which should be executed even if any exception happens }

Description : Write syntax for following commands: i)Sleep ii)Kill

Last Answer : i)sleep Syntax: sleep NUMBER[SUFFIX]… sleep OPTION ii) kill Syntax: kill pid

Description : Write syntax to create view.

Last Answer : Create view as select OR CREATE VIEW name ASSELECT column1, column2.....FROM table_nameWHERE [condition];

Description : Write Syntax for create table.

Last Answer : Syntax of Create table: CREATE TABLE table_name(  column1 datatype (size),  column2 datatype(size),  column3 datatype(size),  ..... columnNdatatype(size)  );

Description : Write the syntax of entity and architecture used in VHDL and explain it.

Last Answer : Entity declaration: It defines the names. Input output signals and modes of a hardware module. Also it provides the external interface of an entity. It is a black box view. Syntax ... _name of entity_ name  Architecture_ declaration_ name;  begin  Statement;  end architecture_ name;

Description : The number of records contained within a block of data on magnetic tape is defined by the A) Block definition B) Record contain clause C) Blocking factor D) Record per block

Last Answer : Answer : C

Description : Pick up the correct definition from the following with response to GIS. (A) Common boundary between two areas of a locality is known as adjacency (B) The area features which are wholly ... property which describes the linkage between line features is defined as connectivity (D) All of these

Last Answer : Answer: Option D

Description : Which of the following terms has been defined by the American Psychiatric Association as a group of behavioral or psychological symptoms or a pattern that manifests itself in significant distress ... of the unknown. d) Schizophrenia Schizophrenia is a specific disorder characterized by psychosis.

Last Answer : a) Mental disorder The definition was adopted by the American Psychiatric Association in 1994.

Description : Capstone’s definition of reach in the marketing module is defined by the potential number of customers who would see the message. Based on this definition what segment has “fair” reach with direct mailing? a. High End b. Traditional c. Low End d. Performance e. Size

Last Answer : a. High End

Description : The number of records contained within a block of data on magnetic tape is defined by the a. Block definition b. Record contain clause c. Blocking factor d. Record per block factor

Last Answer : c. Blocking factor

Description : Which of the following is not an assumption of the classical decision model? (a) Problems are clearly defined. (b) Decision makers behave logically. (c) Evaluation criteria are drawn from ... the definition of the problem. (d) Choice is made once sufficient information on alternatives is available

Last Answer : (d) Choice is made once sufficient information on alternatives is available 

Description : The binding energy of a nucleus is defined as one of the following. Is this definition: w) the energy equivalent to its mass x) the mass difference between its neutrons and protons y) the energy ... the difference between the mass of the nucleus and the sum of the masses of its protons and neutrons

Last Answer : ANSWER: Z -- THE DIFFERENCE BETWEEN THE MASS OF THE NUCLEUS AND THE UM 

Description : HTML is a markup language for describing Web document. HTML uses (a) pre_specified tags (b) user defined tags -Technology

Last Answer : (d) HTML uses fixed tags defined by the language.

Description : Which type of tags used by HTML? (a) tags only for image (b) user defined tags -Technology

Last Answer : (d) HTML provides predefined and fixed tags.

Description : Import a user-defined module in python -Web-Development

Last Answer : answer:

Description : What are the benefits of using user defined functions in the program ?

Last Answer : Answer : In C-Program, the functions that the program describes according to its own needs in the Main () function are called user defined functions or user defined functions. The main advantage of the defined ... you can edit and insert some new data. As a result, the user benefits from the work.

Description : What is the user defined object?

Last Answer : A user-defined object is an instance of a user-defined type,typically a class, or an enum.