Ex No 6
Ex No 6
Aim:
Algorithm:
Step1: Start
Step3: Call the function from main() function along with necessary parameters
Step4: Define the function and return the processed value to the calling function
Step5: Stop
Program:
#include <stdio.h>
// Function declaration
int main() {
int sum;
// Function call
return 0;
// Function definition
Output:
Program:
#include <stdio.h>
// Function declaration
int main() {
// Function call
modifyValue(num);
return 0;
// Function definition
void modifyValue(int x) {
x = 100;
Output:
Program:
#include <stdio.h>
// Function declaration
int main() {
// Function call
modifyValue(&num);
return 0;
// Function definition
*x = 100;
Output:
Program:
#include <stdio.h>
// Function declaration
int main() {
// Function call
printArray(numbers, size);
return 0;
// Function definition
printf("\n");
Output:
Result:
Thus the C programs to demonstrate the concept of function call, return, passing
parameters by value and reference and passing arrays as parameters to function was executed
successfully and the output was verified.
Ex.No.7. Recursion
Date:
Aim:
Algorithm:
Step1: Start
Step2: The condition under which the recursive function will stop calling itself.
Step3: The condition under which the function calls itself with modified arguments.
Step4: Write the function that adheres to the base and recursive cases.
Step6: Stop
Program:
#include <stdio.h>
int main()
int num;
scanf("%d", &num);
if (num < 0)
}
else
return 0;
int factorial(int n)
// Base case
if (n == 0)
return 1;
else
Output:
Factorial of 5 is 120
Result:
Thus the C program to implement the concept of recursion was executed successfully and the
output was verified.