1.4 What do the following declarations signify? void *cmp();
A) cmp is a pointer to an void type.
B) cmp is a void type pointer variable.
C) cmp is a function that return a void pointer.
D) cmp function returns nothing.
Declaration int *(*p) int(*a) is
A) A pointer to function that accept an integer argument and return an integer
B) A pointer to a, which returns an integer
C) A pointer to subroutine which returns an integer
D) None of the above
2 Which of the
following is the correct order if calling functions in the below code?
a = f1(23, 14) * f2(12/4) + f3();
A) f1, f2, f3
B) f3, f2, f1
C) Order may vary
from compiler to compiler
D) None of the
above
4 Which of the following statement is correct
about the following program?
#include<stdio.h>
long fun(int num)
{
int i;
long f=1;
for(i=1; i<=num; i++)
f = f * i;
return f;
}
A) The function
calculates the value of 1 raised to power num
B) The function
calculates the square root of an integer
C) The function
calculates the factorial value of an integer
D) None of the
above
5 Prototype of function named ‘fun’ is: int
fun(int a, float b) Which of the following is
true about
function ‘fun’:
A) It takes two
inputs, one integer type and the other float type but returns nothing
B) It takes two
inputs, one integer type and the other float type but returns 0
C) It takes two
inputs, one integer type and the other float type but returns an integer
D) It takes two
inputs, one integer type and the other integer type but returns float
True false
1.
Functions cannot return more than one value at a
time.
2.
Functions can be called either by value or
reference.
3.
Functions can be called either by value or
reference.
4.
The names of parameters in a function definition
and its declaration must be same.
5.
sizeof() is a function used to determine the
amount of memory occupied by a variable.
6.
The address of the variable is passed to a
function in call by reference.
7.
Functions that do not contain return statement
do not return any value.
8.
In ‘C’, parameters to a function can be passed
by value but not by reference.
9.
Functions may have several declarations, but
only one definition.
10.
Functions can return a floating point number.
11.
In a function two return statements should never
occur.
12.
A ‘C’ function can contain many return
statements.
13.
Functions can be called either by value or by
reference.
14.
The lifetime of a static variable is the
duration of your program's execution.
15.
A function can have any number of return
statements.
16.
void (*ptr)() is a pointer to a function which
receives nothing and returns nothing.
17.
Recursion cannot call a function itself.
18.
A function in ‘C’ must have at least one
argument.
19.
In the declaration int(*p)() p is a pointer to a
function that returns an integer.
20.
In C functions the actual expressions /
parameters are passed on to formal parameters using the method of call by value
result
21.
Match the following
1.
|
Recursion
|
a)
|
Recursion
|
2.
|
Call by reference
|
b)
|
Fn(a)
|
3.
|
Modular Design
|
c)
|
manipulator
|
4.
|
Calls itself
|
d)
|
Fn(&a)
|
5.
|
A function that change state object is
called
|
e)
|
Must be declared as void
|
6.
|
Recursion
|
f)
|
Ferror()
|
7.
|
A function that returns objects of different types
|
g)
|
Easy to debug
|
8.
|
Function that detects error in file
accessing
|
h)
|
a function calling itself
|
(B)
1.
|
Value of static storage variable
|
a)
|
where a function call itself
|
2.
|
int(*pp)(void*,void*)
|
b)
|
Integer value
|
3.
|
by default, functions return
|
c)
|
Persists between different function
calls
|
4.
|
recursion is a process
|
d)
|
pp is function that returns pointer
to integer
|
Fill in the blanks
1.
|
Sizeof(float)
|
2.
|
relational
|
3.
|
static
|
4.
|
lvalue
|
5.
|
fn(int q, char c)
|
6.
|
Call by value
|
7.
|
parameter
|
8.
|
{}
|
9.
|
local
|
10.
|
Int
|
11.
|
12.
|
||
13.
|
RAM
|
14.
|
Stdio.h
|
15.
|
overflow
|
16.
|
value
|
1. The argument list of function is known as function’s
________.
2. In compiler ________ error messages means that an object
on left hand side of assignment operator is missing.
3. A function call for a function with the declaration void
fn(int x, char c); is ________.
4. The ________ operators are used to compare the values of
integers.
5. If *pf is a pointer to float, then ++pf will
increment its value by ________.
6. The brackets used to mark the boundaries of a block are
________.
7.
8. A function call mechanism that passes arguments to a
function by passing a copy of the values of the arguments is ________.
9 An example of volatile memory is ________.
10 If a function is defined as fn(char a){ … }, then its
return type is ________.
11 A variable declared inside a function is called ________
variable.
12 Many recursive calls may result into stack ________.
13 When a variable is passed to a function, by ________, its
value remains unchanged in the calling program.
14 Input/output function prototypes and macros are defined
in ________.
Question-
1 What is the purpose of using functions in ‘C’ programming? Differentiate declaration and definition of a function.
2 How will you pass parameters to a function? Briefly describe two mechanisms of parameter passing in ‘C’ language.
3 What is difference between pass by value and pass by reference?
4 Write a C program which calls a function to swap values of two variables.
5 Write a function to swap two integers. The function does not return any value.
5 Write a function to swap two integers. The function does not return any value.
6 Develop a function to calculate sum of n even integers starting from a given even integer.
7. Write a program to find the power of number using
function.
8 Write a function to display the multiplication table of the number.
9. Define void data type and write any three use of it.
10 Write a program having function print_char( ) which
receives a character and n integer as arguments. The function should print n
times the entered character
11 What is the output of the following program?
#include void fun(int*, int*);
int main()
{
int i=5, j=2;
fun(&i, &j);
printf("%d, %d", i, j);
return 0;
}
void fun(int *i, int *j)
{
*i = *i**i;
*j = *j**j;
}
12 Consider outline of ‘C’ program given below: #Include suitable header files
void main()
{
suitable prototype of function
interchange()
int a=10, b=20;
interchange(&a,&b);
printf(“a=%d b=%d”,a,b)
}
The function interchange() interchanges the values of the variables supplied to it. So the output of the program is
a=20 b=10
Write suitable interchange() function. Also fill in the gaps of this program so that it produces the desired output.
13 Write a function which accepts an integer array of size n and prints every third value of the array.
14 Write a c program to find out factorial of given number
using function recursion.
or
Write a program having a recursive function to calculate the factorial of a number. In the main() function, read the value of the number and then using the recursive function display the result.
or
Write a program having a recursive function to calculate the factorial of a number. In the main() function, read the value of the number and then using the recursive function display the result.
15. Write a C program to read a line and print it reverse using recursive function.
14 Define recursion. Write a complete program to evaluate the given series using recursive function sum( ).
Here n is user dependent. 1 + 2 + 3 +…+ n
20) Write a recursive function to compute factorial of a number.
4. Write a program having a recursive function to calculate the factorial of a number. In the main() function, read the value of the number and then using the recursive function display the result.
20) Write a recursive function to compute factorial of a number.
4. Write a program having a recursive function to calculate the factorial of a number. In the main() function, read the value of the number and then using the recursive function display the result.
13 Write a program to compute the following series: x + x3 / 3! + x5 / 5! + …
To a given accuracy for x from 00 to 1800 in the steps of 100 , use a inbuilt function FACT(n) to compute the factorial.
1. Write a function that will compute Y = X^n Where Y and X are floating point numbers and n is an integer number. Use this function and print the output
22 Write a function that takes time in seconds as input and prints it in terms of hours, minutes and seconds.
1. Write a function that will compute Y = X^n Where Y and X are floating point numbers and n is an integer number. Use this function and print the output
X n Y … … …
22 Write a function that takes time in seconds as input and prints it in terms of hours, minutes and seconds.
Jsko bi C Programming language in Hindi m thori pandi h wo yha per padle
ReplyDeletehttp://sunil258.blogspot.com