Chapter 3 - Type C - Programming Based Questions
Chapter 3 - Type C - Programming Based Questions
1. Write a function that takes amount-in-dollars and dollar-to-rupee conversion price ; it then
returns the amount converted to rupees. Create the function in both void and non-void forms
CODING:
OUTPUT:
2. Write a function to calculate volume of a box with appropriate default values for its parameters.
Your function should have the following input parameters: (a) length of box ; (b) width of box ;
(c) height of box.
CODING:
OUTPUT:
1
3. A function that takes a number as argument and calculates cube for it. The function does not
return a value. If there is no value passed to the function in function call, the function should
calculate cube of 2.
(ii) A function that takes two char arguments and returns True if both the arguments are equal
otherwise False.
Test both these functions by giving appropriate function call statements.
CODING: OUTPUT
4. Write a function that receives two numbers and generates a random number from that range
Using this function, the main program should be able to print three numbers randomly.
CODING:
OUTPUT:
2
5. Write a function that receives two string arguments & checks whether they are same-length strings .
CODING:
OUTPUT:
6. Write a function namely nthRoot () that receives two parameters x and n and returns nth root of
x i.e., X**1/n . The default value of n is 2
CODING:
OUTPUT:
3
7. Write a function that takes a number n and then returns a randomly generated number having
exactly n digits (not starting with zero) eg ., if n is 2 then function can randomly return a number
10-99 but 07, 02 etc. are not valid two-digit numbers.
CODING:
OUTPUT:
8. Write a function that takes two numbers and returns the number that has minimum one's digit.
[For example, if numbers passed are 491 and 278, then the function will return 491 because it has
got minimum one's digit out of two given numbers (491's 1 is < 278's 8)].
CODING:
OUTPUT:
4
9. Write a program that generates a series using a function which takes first and last values of the
series and then generates four terms that are equidistant e.g., if two numbers passed are 1 and 7
then function returns 1 3 5 7
CODING:
OUTPUT: