Sei sulla pagina 1di 2

Lab Task 15 April 15 - Function

1. Input two integer values in main function and pass them to a function
named add(int,int). The function named add() will add those two
values and output inside it.
2. Input two integer values in main function and pass them to a function
named add(int a,int b). The function named add(int a,int b) will
add those two values and return the result to main() function. Main
should receive the result and output.
3. Write another function named add2() that should not take any
parameter but input two values inside it and output the addition
result into DOS.
4. Write a function named square(int v). That will take an integer value
as parameter and output the square value in it. Provide a value to
square(int v) when calling it from main() function. That function
should output the square of v.
5. Using a loop that runs for 1,2,3,4 and 5, call the previously written
function square(int v) for each of the values. The loop will repeatedly
call the function and provide the values from 1 to 5 and square them.
That function should receive each of those values in v and output the
square of v each time. [ square() function should be called inside the
loop, loop rotates 5 times ]
6. Write a C program that will have a function named print_max () that
will find the largest number from a one dimensional array and output
the largest value inside that function. Declare an array of integer
values inside function and output the largest value. You should call the
print_max() from main().
7. Write a C program that will have a function named get_max () that
will find the largest number from a one dimensional array and return
the largest value to main function. Output the largest value in the main
function.
8. Inside a function named search(int target) there will be an array
declared with some initial values. That function will take an integer
value as a parameter and search whether it is available in the array or
not.
9. Write a C function that will find the smallest number from a one
dimensional array. [Use double type array].
10.
Write a C function that will find the summation and average of
the numbers from an one dimensional array. The function will output
the summation value inside it and return the average result to main
function. Main function should output the average result.

11.
Write a C function that will find a specific value (which will be
given by the user in main function) from a one dimensional array. [Use
any type of array]. If no value matches then it will print No match
found, else it should print match found.

Note : Zip the folder renaming it by using your ID and upload it


within 4:58 pm.

Potrebbero piacerti anche