x

C language question

88 views

2 Answers

Answer :

A function is a group of statements that is executed, when it is called from some point of the program.

A function is self contained block of statement written once in a program but can be used again & again.

A function is called or invoked by a function call. The function call specifies the function name and provides information (arguments) that the called function needs to do its job.

Functions allow the programmer to modularized a program. All variables declared in function definition are local variable. They are known only in the function in the way they are defined.

Function Definition:

A function definition contains name of the function with it return type, the formal arguments to be passed in the brackets if any and the body of the function which contains executable statements.

The syntax of function declaration is—

Function return type function name ( data type arg1, data type arg2, ………………)

{

--------------------------------------------

--------------------------------------------

Body of the function

--------------------------------------------

--------------------------------------------

Return value

}

In above function declaration return type should be any fundamental data types like, int, float, char etc. In case the function does not return any value than the type of function will be taken as void.
Like 0 like

Answer :

The Function Return Type

 The function return type specifies the data type that the function returns to the calling program.

 The return type can be any of C′s data types: char, int , long , float , or double .

 One can also define a function that doesn′t return a value by using a return type of void. 


Program – A function that return the maximum between two numbers
int max(int num1, int num2)
{ /* local variable declaration */
 int result;
 if (num1>num2)
 result=num1;
else
 result=num2;

 return result;
}
void main()
{ int r;
 r=max( 10,15);
print(“Result = %d “ , r);

Like 0 like

Please log in or register to answer this question.

Related Questions


In C++, the keyword void was used ……….. A) To specify the return type of function when it is not returning any value. B) To indicate an empty argument list to a function. C) To declare the generic pointers. D) All of the above.
Last Answer : D) All of the above.

Show More

18 views 1 answer

Random Images

State True or False i) A destructor never takes any argument nor does it return any value. ii) It releases memory space for future use. A) True, True B) True, False C) False, True D) False, False
Last Answer : A) True, True

Show More

47 views 1 answer

Random Images

Some of the situations where inline expansion may not work are: A) For functions returning values, if a loop, a switch or goto exists. B) If functions contain static variables and they are re-cursive. C) For functions not returning values, if return statement exist. D) All of the above.
Last Answer : D) All of the above.

Show More

42 views 1 answer

Random Images

Random Images

Which of the following condition is true for an object used as a function argument. i) A copy of the entire objects is passed to the function. ii) Only the address of the object is transferred to the function. A) Only i B) Only ii C) Both i and ii D) None of them
Last Answer : C) Both i and ii

Show More

15 views 1 answer

Random Images

Can there be multiple return statements in a function?
Last Answer : A: Yes, but only one of them is executed.

Show More

3 views 1 answer

Random Images

What does the following expression means ? char *(*(* a[N]) ( )) ( ); (A) a pointer to a function returning array of n pointers to function returning character pointers. (B) a ... to characters (D) an array of n pointers to function returning pointers to functions returning pointers to characters.
Last Answer : Answer: A,B,C,D

Show More

47 views 1 answer

Random Images

What is the value returned by the function f given below when n = 100 ? int f(int n)  { if (n==0) then return n;  else return n + f(n-2);  } (A) 2550 (B) 2556 (C) 5220 (D) 5520
Last Answer : (A) 2550

Show More

34 views 1 answer

Random Images

To accept 100 different values into the array we require A) Loop B) If condition C) Function D) Structure
Last Answer : A) Loop

Show More

147 views 1 answer

Random Images

When an array is passed as a parameter to a function which of the following statements is correct? (A) The function can change values in the original array. (B) The function cannot change values in the original array. (C) Results in compilation error. (D) Results in runtime error.
Last Answer : (A) The function can change values in the original array.

Show More

323 views 1 answer

Random Images

When an array is passed as parameter to a function, which of the following statements is correct ? (A) The function can change values in the original array. (B) In C, parameters are passed by value, ... . (D) Results in a run time error when the function tries to access the elements in the array.
Last Answer : (A) The function can change values in the original array.

Show More

83 views 1 answer

Random Images

The number of function points of a proposed system is calculated as 500. Suppose that the system is planned to be developed in Java and the LOC/FP ratio of Java is 50. Estimate the effort (E) required to ... ) 25 person months (B) 75 person months (C) 62.5 person months (D) 72.5 person months
Last Answer : (C) 62.5 person months 

Show More

150 views 1 answer

Random Images

What would happen if "String[]args" is not included as argument in the main method. A) No error B) Compilation error C) Program won't run D) Program exit
Last Answer : C) Program won't run

Show More

326 views 1 answer

Random Images

A ……………. takes a reference to an object of the same class as itself as an argument. A) Reference constructor B) Copy Constructor C) Self Constructor
Last Answer : B) Copy Constructor

Show More

22 views 1 answer

Random Images

Random Images

What set of all values that a function will return as outputs is called the of the function?
Last Answer : Need answer

Show More

2 views 1 answer

Random Images

What is the use of return keyword?
Last Answer : A: return keyword is used to return any value from a function. It denotes the end of a function.

Show More

5 views 1 answer

Random Images

What does System.in.read() return?
Last Answer : A: It returns the number of bytes read from the Input Stream as an integer.

Show More

2 views 1 answer

Random Images

Methods can be overloaded with a difference only in the type of the return value .. A) Not supported B) False C) True D) None of the above
Last Answer : B) False

Show More

72 views 1 answer

Random Images

Which of the following do not represent legal flow control statements? A) break; B) return; C) exit(); D) continue outer;
Last Answer : C) exit();

Show More

10 views 1 answer

Random Images

Which of the following do not represent legal flow control statements? A) break; B) return; C) exit(); D) continue outer;
Last Answer : C) exit();

Show More

93 views 1 answer

Random Images

State True or False. i) While overloading operators new operator can be overloaded. ii) The binary operator such as +, -, * and must explicitly return a value. A) True, True B) True, False C) False, True D) False, False
Last Answer : C) False, True

Show More

249 views 1 answer

Random Images

Which of the following characteristics of constructor are true. i) They should be declared in the public section. ii) They are invoked automatically when the objects are created. iii) They do not have return type and void also. ... and v C) Only i, iii, iv and v D) All i, ii, iii, iv and v
Last Answer : D) All i, ii, iii, iv and v

Show More

231 views 1 answer

Random Images

If a is an integer variable, a=7/3; will return a value A) 2.5 B) 3 C) 0 D) 2
Last Answer : D) 2

Show More

25 views 1 answer

Random Images

The rate of ……………. Is always an important factor for management especially in relation to the rate of return A) Cost B) Benefit C) Sales D) Investment
Last Answer : D) Investment

Show More

10 views 1 answer

Random Images

Which of the following commands would return process_id of sleep command? (A) Sleep 1 and echo $? (B) Sleep 1 and echo $# (C) Sleep 1 and echo $x (D) Sleep 1 and echo $!
Last Answer : (D) Sleep 1 and echo $!

Show More

43 views 1 answer

Random Images

Consider the following three SQL queries (Assume the data in the people table) : (a) Select Name from people where Age>21; (b) Select Name from people where Height>180; (c) Select Name from people where (Age>21) or (Height ... number of rows returned by the SQL query (c) ? (A) 3 (B) 7 (C) 10 (D) 21
Last Answer : (C) 10

Show More

114 views 1 answer

Random Images

Implicit return type of a class constructor is: (A) not of class type itself (B) class type itself (B) a destructor of class type (D) a destructor not of class type 
Last Answer : (B) class type itself

Show More

54 views 1 answer

Random Images

Consider the following JAVA program: public class First { public static int CBSE (int x) { if (x < 100) x = CBSE (x +10); return (x - 1); } public static void main (String[] args){ System.out.print(First.CBSE(60)); } } What does this program print? (1) 59 (2) 95 (3) 69 (4) 99
Last Answer : (2) 95 

Show More

65 views 1 answer

Random Images

What will be the values of x, m and n after execution of the following statements? Int x, m, n; m=10; n=15; x= ++m + n++; A) x=25, m=10, n=15 B) x=27, m=10, n=15 C) x=26, m=11, n=16 D) x=27, m=11, n=16
Last Answer : C) x=26, m=11, n=16

Show More

22 views 1 answer

Random Images

In a queue, the initial values of front pointer f rare pointer r should be ….. and …….. respectively. A) 0 and 1 B) 0 and -1 C) -1 and 0 D) 1 and 0
Last Answer : B) 0 and -1

Show More

144 views 1 answer

Random Images

Which of the syntax is correct for insert statement? i) insert into values ii) insert into (column list) values A) i-only B) ii-only C) Both of them D) None of them
Last Answer : C) Both of them

Show More

189 views 1 answer

Random Images

……………….. contains information that defines valid values that are stored in a column or data type. A) View B) Rule C) Index D) Default
Last Answer : C) Index

Show More

47 views 1 answer

Random Images

149 views 2 answers

Random Images

One aspect that has to be dealt with by the integrity subsystem is to ensure that only valid values can be assigned to each data items. This is referred to as A) Data Security B) Domain access C) Data Control
Last Answer : C) Data Control

Show More

43 views 1 answer

Random Images

A set of possible data values is called (A) attribute. (B) degree. (C) tuple. (D) domain.
Last Answer : D) domain.

Show More

30 views 1 answer

Random Images

If f(x, y) is a digital image, then x, y and amplitude values of f are (A) Finite (B) Infinite (C) Neither finite nor infinite (D) None of the above
Last Answer : (A) Finite

Show More

40 views 1 answer

Random Images

For a database relation R(a, b, c, d) where the domains of a, b, c, d include only the atomic values. The functional dependency a → c, b → d holds in the following relation (A) In 1NF not in 2NF (B) In 2NF not in 3NF (C) In 3NF (D) In 1NF
Last Answer : (A) In 1NF not in 2NF 

Show More

90 views 1 answer

Random Images

How many values can be held by an array A(-1,m;1 ,m) ? (A) m (B) m2 (C) m(m+l) (D) m(m+2)
Last Answer : (D) m(m+2) Explanation: Total number of values =m(m+2). Because -1 to m, m+2 values and 1 to m, m values

Show More

55 views 1 answer

Random Images

What are the final values of Q1 and Q0 after 4 clock cycles, if initial values are 00 in the sequential circuit shown below: (A) 11 (B) 10 (C) 01 (D) 00
Last Answer : (D) 00

Show More

52 views 1 answer

Random Images

For a weak entity set to be meaningful, it must be associated with another entity set in combination with some of their attribute values, is called as : (A) Neighbour Set (B) Strong Entity Set (C) Owner entity set (D) Weak Set
Last Answer : (C) Owner entity set 

Show More

117 views 1 answer

Random Images

Consider a full-adder with the following input values: (a) x=1, y=0 and Ci(carry input) = 0 (b) x=0, y=1 and Ci = 1 Compute the values of S(sum) and C0 (carry output) for the above input values. (A) S=1 , C0= 0 and ... C0= 1 (C) S=1 , C0= 1 and S=0 , C0= 0 (D) S=0 , C0= 1 and S=1 , C0= 0
Last Answer : (A) S=1 , C0= 0 and S=0 , C0= 1

Show More

62 views 1 answer

Random Images

In constraint satisfaction problem, constraints can be stated as . (A) Arithmatic equations and inequalities that bind the values of variables (B) Arithmatic equations and inequalities ... impose restrictions over variables (D) Arithmatic equations that discard constraints over the given variables
Last Answer : (A) Arithmatic equations and inequalities that bind the values of variables

Show More

29 views 1 answer

Random Images

Let P(m,n) be the statement m divides n where the Universe of discourse for both the variables is the set of positive integers. Determine the truth values of the following propositions. (a) ∃m ∀n P(m,n) (b) ∀n P(1,n) ( ... -False (C) (a)-False; (b)-False; (c)-False (D) (a)-True; (b)-True; (c)-True
Last Answer : Answer: A

Show More

85 views 1 answer

Random Images

A server crashes on the average once in 30 days, that is, the Mean Time Between Failures (MTBF) is 30 days. When this happens, it takes 12 hours to reboot it, that is, the Mean Time to Repair (MTTR) is 12 ... these reliability data values is approximately: (A) 96.3% (B) 97.3% (C) 98.3% (D) 99.3%
Last Answer : (C) 98.3%

Show More

37 views 1 answer

Random Images

Consider the following database table having A, B, C and D as its four attributes and four possible candidate keys (I, II, III and IV) for this table: I: {B} II: {B, C} III: {A, D} IV: {C, D} If ... the database table? (A) I and III only (B) III and IV only (C) II only (D) I only
Last Answer : (C) II only

Show More

63 views 1 answer

Random Images

In a relational database model, NULL values can be used for all but which one of the following? (A) To allow duplicate tuples in the table by filling the primary key column(s) with NULL. (B) To ... D) To fill a column in a tuple when that column does not really exist for that particular tuple.
Last Answer : (A) To allow duplicate tuples in the table by filling the primary key column(s) with NULL.

Show More

196 views 1 answer

Random Images

Consider the following Entity-Relationship (E-R) diagram and three possible relationship sets (I, II and III) for this E-R diagram: If different symbols stand for different values (e.g., t1 is definitely not equal to t2 ... diagram ? (A) I only (B) I and II only (C) II only (D) I, II and III
Last Answer : (A) I only

Show More

152 views 1 answer

Random Images

Random Images

For a database relation R(A,B,C,D) where the domains of A,B,C and D include only atomic values, only the following functional dependencies and those that can be inferred from them are: A→C B→D The ... form but not in third normal form (4) Both in second normal form as well as in third normal form
Last Answer : First normal form but not in second normal form

Show More

50 views 1 answer

Random Images
Show More⇦ PreviousNext ⇨