UNIT III FUNCTIONS AND POINTERS
Modular programming – Function prototype, function definition, function call, Built-in
functions (string functions, math functions) – Recursion, Binary Search using recursive
functions –Pointers – Pointer operators – Pointer arithmetic – Arrays and pointers – Array of
pointers – Parameter passing: Pass by value, Pass by reference.1. Modular Programming –
Function Prototype
Definition: A function prototype is a declaration of a function that provides the compiler with
information about the function's name, return type, and parameter types. It does not include the
function body. Prototypes are essential for type checking and help in modularizing code.
Syntax:
return_type function_name(parameter_list);
Example:
int add(int a, int b); // Function prototype
int main() {
int result = add(5, 3);
printf("Sum: %d", result);
return 0;
}
int add(int a, int b) { // Function definition
return a + b;
}
Program from T1 Chapter 11:
#include <stdio.h>
float area(float radius);
int main() {
float r;
printf("Enter radius: ");
scanf("%f", &r);
printf("Area: %.2f", area(r));
return 0;
}
float area(float radius) {
return 3.14 * radius * radius;
}
Purpose of Function Prototype:
1. Ensures type safety by allowing the compiler to verify function calls.
2. Enables the use of functions before their definition.
3. Facilitates modular programming by separating declarations and definitions.
Advantages of Modular Programming:
Enhances code readability.
Simplifies debugging and maintenance.
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
Promotes code reuse and teamwork.
Reference: T1 Chapter 11, pp. 221-240; T2 Chapter 4, pp. 66-75
2. Function Definition and Function Call
Function Definition: A function definition provides the actual implementation of the function. It
specifies what the function does and includes the function body.
Syntax:
return_type function_name(parameters) {
// Function body
return value; // Optional, depending on return type
}
Example:
int multiply(int a, int b) {
return a * b;
}
Program from R1 Chapter 6:
#include <stdio.h>
void displayMessage();
int main() {
displayMessage();
return 0;
}
void displayMessage() {
printf("Hello, this is a function call example!\n");
}
Function Call: A function call is used to invoke a function. The parameters passed during the call are
substituted into the function definition.
Example:
int result = multiply(4, 5); // Calls the function and stores the result
printf("Product: %d", result); // Output: Product: 20
Steps in a Function Call:
1. The program control is transferred to the function.
2. The arguments are passed to the function parameters.
3. The function executes its statements.
4. The control is returned to the calling function with or without a value.
Reference: R1 Chapter 6, pp. 90-100
3. Built-in Functions (String Functions and Math Functions)
String Functions (from string.h):
1. strlen() – Returns the length of a string.
o Example:
o char str[] = "Hello";
printf("Length: %d", strlen(str)); // Output: 5
2. strcpy() – Copies one string to another.
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
o Example:
o char src[] = "World";
o char dest[10];
o strcpy(dest, src);
printf("Copied String: %s", dest); // Output: World
3. strcmp() – Compares two strings lexicographically.
o Example:
o if (strcmp("apple", "banana") < 0)
printf("Apple comes first");
Program from T1 Chapter 11:
#include <stdio.h>
#include <string.h>
int main() {
char str1[20], str2[20];
printf("Enter two strings: ");
scanf("%s %s", str1, str2);
if (strcmp(str1, str2) == 0)
printf("Strings are equal\n");
else
printf("Strings are not equal\n");
return 0;
}
Math Functions (from math.h):
1. sqrt() – Computes the square root of a number.
o Example:
printf("Square Root: %.2f", sqrt(16.0)); // Output: 4.00
2. pow() – Computes power.
o Example:
printf("Power: %.2f", pow(2, 3)); // Output: 8.00
Program from R5 Chapter 6:
#include <stdio.h>
#include <math.h>
int main() {
double x = 9.0;
printf("Square Root: %.2f\n", sqrt(x));
printf("Power: %.2f\n", pow(2, 3));
return 0;
}
Reference: T1 Chapter 11, pp. 241-250; R1 Chapter 6, pp. 300-320; R5 Chapter 6, pp. 120-135
4. Recursion
Definition: Recursion is a programming technique where a function calls itself to solve a smaller
subproblem. It continues until a base case is met.
Components:
1. Base Case – Terminates recursion.
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
2. Recursive Case – The function calls itself with modified parameters.
Example: Factorial Using Recursion
int factorial(int n) {
if (n == 0)
return 1; // Base case
return n * factorial(n - 1); // Recursive case
}
Program from T1 Chapter 11:
#include <stdio.h>
int factorial(int n);
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
printf("Factorial: %d", factorial(num));
return 0;
}
int factorial(int n) {
if (n == 0)
return 1;
return n * factorial(n - 1);
}
Advantages:
Simplifies problems like tree traversal, Fibonacci series, and factorial calculation.
Disadvantages:
Can lead to stack overflow if not properly handled.
May be less efficient due to overheads.
Reference: T1 Chapter 11, pp. 250-265; T2 Chapter 4, pp. 78-85
5. Binary Search Using Recursive Functions
Definition: Binary search is a searching algorithm that works on sorted arrays. It repeatedly divides
the search interval in half to find the target element.
Algorithm:
1. Calculate the mid-point.
2. Compare the middle element with the target.
3. If they match, return the index.
4. If the target is smaller, search in the left half.
5. If the target is larger, search in the right half.
Recursive Implementation:
int binarySearch(int arr[], int low, int high, int key) {
if (low > high)
return -1; // Element not found
int mid = (low + high) / 2;
if (arr[mid] == key)
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
return mid;
else if (arr[mid] > key)
return binarySearch(arr, low, mid - 1, key);
else
return binarySearch(arr, mid + 1, high, key);
}
Program from R3 Chapter 7:
#include <stdio.h>
int binarySearch(int arr[], int low, int high, int key);
int main() {
int arr[] = {10, 20, 30, 40, 50};
int n = sizeof(arr) / sizeof(arr[0]);
int key;
printf("Enter key to search: ");
scanf("%d", &key);
int result = binarySearch(arr, 0, n - 1, key);
if (result != -1)
printf("Element found at index %d", result);
else
printf("Element not found");
return 0;
}
int binarySearch(int arr[], int low, int high, int key) {
if (low > high)
return -1;
int mid = (low + high) / 2;
if (arr[mid] == key)
return mid;
else if (arr[mid] > key)
return binarySearch(arr, low, mid - 1, key);
else
return binarySearch(arr, mid + 1, high, key);
}
Reference: R3 Chapter 7, pp. 190-200
6. Pointers, Pointer Operators, and Pointer Arithmetic
Definition: A pointer is a variable that stores the memory address of another variable.
Pointer Operators:
1. & (Address-of Operator): Retrieves the address of a variable.
o Example:
o int a = 5;
int *ptr = &a;
2. * (Dereference Operator): Accesses the value stored at the address.
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
o Example:
printf("Value: %d", *ptr); // Output: 5
Pointer Arithmetic:
1. Incrementing a pointer moves it to the next memory location.
o Example:
o int arr[] = {10, 20, 30};
o int *ptr = arr;
o ptr++;
printf("Next Value: %d", *ptr); // Output: 20
Program from T1 Chapter 13:
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30, 40};
int *ptr = arr;
for (int i = 0; i < 4; i++) {
printf("Value: %d Address: %p\n", *ptr, ptr);
ptr++;
}
return 0;
}
Reference: T1 Chapter 13, pp. 271-290; T2 Chapter 5, pp. 98-115; R4 Chapter 7, pp. 145-160
7. Arrays and Pointers
Definition: The name of an array acts as a pointer to its first element.
Examples:
1. Accessing Array Elements Using Pointers:
2. int arr[3] = {1, 2, 3};
3. int *ptr = arr;
4. for (int i = 0; i < 3; i++) {
5. printf("%d ", *(ptr + i));
}
6. Array of Pointers:
o Example:
o char *names[] = {"Alice", "Bob", "Charlie"};
printf("%s", names[1]); // Output: Bob
Program from T1 Chapter 13:
#include <stdio.h>
int main() {
char *names[] = {"Alice", "Bob", "Charlie"};
for (int i = 0; i < 3; i++) {
printf("Name[%d]: %s\n", i, names[i]);
}
return 0;
}
Reference: T1 Chapter 13, pp. 290-305; T2 Chapter 5, pp. 115-120
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
8. Parameter Passing: Pass by Value and Pass by Reference
Pass by Value:
A copy of the argument is passed to the function. The original value remains unchanged.
Example:
void changeValue(int x) {
x = 20;
}
int main() {
int a = 10;
changeValue(a);
printf("%d", a); // Output: 10
}
Pass by Reference:
The address of the argument is passed, allowing the function to modify the original value.
Example:
void changeValue(int *x) {
*x = 20;
}
int main() {
int a = 10;
changeValue(&a);
printf("%d", a); // Output: 20
}
Program from T1 Chapter 11:
#include <stdio.h>
void swap(int *x, int *y);
int main() {
int a = 5, b = 10;
printf("Before Swap: a = %d, b = %d\n", a, b);
swap(&a, &b);
printf("After Swap: a = %d, b = %d\n", a, b);
return 0;
}
void swap(int *x, int *y) {
int temp = *x;
*x = *y;
*y = temp;
}
Reference: T1 Chapter 11, pp. 265-275; R2 Chapter 5, pp. 130-140
1. Modular Programming – Function Prototype
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
Definition: A function prototype is a declaration of a function that provides the compiler with
information about the function's name, return type, and parameter types. It does not include the
function body. Prototypes are essential for type checking and help in modularizing code.
Syntax:
return_type function_name(parameter_list);
Example:
int add(int a, int b); // Function prototype
int main() {
int result = add(5, 3);
printf("Sum: %d", result);
return 0;
}
int add(int a, int b) { // Function definition
return a + b;
}
Program from T1 Chapter 11:
#include <stdio.h>
float area(float radius);
int main() {
float r;
printf("Enter radius: ");
scanf("%f", &r);
printf("Area: %.2f", area(r));
return 0;
}
float area(float radius) {
return 3.14 * radius * radius;
}
Possible Programs:
1. Write a program to calculate the circumference of a circle using a function prototype.
2. Develop a program to check if a number is even or odd using a function prototype.
3. Create a program to convert Celsius to Fahrenheit using a function prototype.
Reference: T1 Chapter 11, pp. 221-240; T2 Chapter 4, pp. 66-75
2. Function Definition and Function Call
Function Definition: A function definition provides the actual implementation of the function. It
specifies what the function does and includes the function body.
Syntax:
return_type function_name(parameters) {
// Function body
return value; // Optional, depending on return type
}
Example:
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
int multiply(int a, int b) {
return a * b;
}
Program from R1 Chapter 6:
#include <stdio.h>
void displayMessage();
int main() {
displayMessage();
return 0;
}
void displayMessage() {
printf("Hello, this is a function call example!\n");
}
Possible Programs:
1. Write a program to calculate the average of three numbers using a user-defined function.
2. Create a program to display the largest of three numbers using a function call.
3. Develop a program to reverse a string using a function.
Reference: R1 Chapter 6, pp. 90-100
3. Built-in Functions (String Functions and Math Functions)
String Functions (from string.h):
1. strlen() – Returns the length of a string.
o Example:
o char str[] = "Hello";
printf("Length: %d", strlen(str)); // Output: 5
2. strcpy() – Copies one string to another.
o Example:
o char src[] = "World";
o char dest[10];
o strcpy(dest, src);
printf("Copied String: %s", dest); // Output: World
3. strcmp() – Compares two strings lexicographically.
o Example:
o if (strcmp("apple", "banana") < 0)
printf("Apple comes first");
Program from T1 Chapter 11:
#include <stdio.h>
#include <string.h>
int main() {
char str1[20], str2[20];
printf("Enter two strings: ");
scanf("%s %s", str1, str2);
if (strcmp(str1, str2) == 0)
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
printf("Strings are equal\n");
else
printf("Strings are not equal\n");
return 0;
}
Math Functions (from math.h):
1. sqrt() – Computes the square root of a number.
o Example:
printf("Square Root: %.2f", sqrt(16.0)); // Output: 4.00
2. pow() – Computes power.
o Example:
printf("Power: %.2f", pow(2, 3)); // Output: 8.00
Program from R5 Chapter 6:
#include <stdio.h>
#include <math.h>
int main() {
double x = 9.0;
printf("Square Root: %.2f\n", sqrt(x));
printf("Power: %.2f\n", pow(2, 3));
return 0;
}
Possible Programs:
1. Write a program to compare two strings using strcmp() and display the result.
2. Create a program to calculate the area and perimeter of a circle using math.h functions.
3. Develop a program to concatenate two strings using strcat() and display the result.
Reference: T1 Chapter 11, pp. 241-250; R1 Chapter 6, pp. 300-320; R5 Chapter 6, pp. 120-135
4. Recursion
Definition: Recursion is a programming technique where a function calls itself to solve a smaller
subproblem. It continues until a base case is met.
Components:
1. Base Case – Terminates recursion.
2. Recursive Case – The function calls itself with modified parameters.
Example: Factorial Using Recursion
int factorial(int n) {
if (n == 0)
return 1; // Base case
return n * factorial(n - 1); // Recursive case
}
Program from T1 Chapter 11:
#include <stdio.h>
int factorial(int n);
int main() {
int num;
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
printf("Enter a number: ");
scanf("%d", &num);
printf("Factorial: %d", factorial(num));
return 0;
}
int factorial(int n) {
if (n == 0)
return 1;
return n * factorial(n - 1);
}
Possible Programs:
1. Write a recursive program to calculate the Fibonacci series up to n terms.
2. Develop a recursive program to reverse a number.
3. Create a recursive program to find the greatest common divisor (GCD) of two numbers.
Reference: T1 Chapter 11, pp. 250-265; T2 Chapter 4, pp. 78-85
5. Binary Search Using Recursive Functions
Definition: Binary search is a searching algorithm that works on sorted arrays. It repeatedly divides
the search interval in half to find the target element.
Algorithm:
1. Calculate the mid-point.
2. Compare the middle element with the target.
3. If they match, return the index.
4. If the target is smaller, search in the left half.
5. If the target is larger, search in the right half.
Recursive Implementation:
int binarySearch(int arr[], int low, int high, int key) {
if (low > high)
return -1; // Element not found
int mid = (low + high) / 2;
if (arr[mid] == key)
return mid;
else if (arr[mid] > key)
return binarySearch(arr, low, mid - 1, key);
else
return binarySearch(arr, mid + 1, high, key);
}
Program from R3 Chapter 7:
#include <stdio.h>
int binarySearch(int arr[], int low, int high, int key);
int main() {
int arr[] = {10, 20, 30, 40, 50};
int n = sizeof(arr) / sizeof(arr[0]);
int key;
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
printf("Enter key to search: ");
scanf("%d", &key);
int result = binarySearch(arr, 0, n - 1, key);
if (result != -1)
printf("Element found at index %d", result);
else
printf("Element not found");
return 0;
}
int binarySearch(int arr[], int low, int high, int key) {
if (low > high)
return -1;
int mid = (low + high) / 2;
if (arr[mid] == key)
return mid;
else if (arr[mid] > key)
return binarySearch(arr, low, mid - 1, key);
else
return binarySearch(arr, mid + 1, high, key);
}
Possible Programs:
1. Write a program to perform linear search iteratively and recursively.
2. Develop a program to implement binary search iteratively.
3. Create a program to count the occurrences of a key using binary search logic.
Reference: R3 Chapter 7, pp. 190-200
6. Pointers, Pointer Operators, and Pointer Arithmetic
Definition: A pointer is a variable that stores the memory address of another variable.
Pointer Operators:
1. & (Address-of Operator): Retrieves the address of a variable.
o Example:
o int a = 5;
int *ptr = &a;
2. * (Dereference Operator): Accesses the value stored at the address.
o Example:
printf("Value: %d", *ptr); // Output: 5
Pointer Arithmetic:
1. Incrementing a pointer moves it to the next memory location.
o Example:
o int arr[] = {10, 20, 30};
o int *ptr = arr;
o ptr++;
printf("Next Value: %d", *ptr); // Output: 20
Program from T1 Chapter 13:
#include <stdio.h>
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
int main() {
int arr[] = {10, 20, 30, 40};
int *ptr = arr;
for (int i = 0; i < 4; i++) {
printf("Value: %d Address: %p\n", *ptr, ptr);
ptr++;
}
return 0;
}
Possible Programs:
1. Write a program to swap two numbers using pointers.
2. Create a program to find the sum of all elements in an array using pointers.
3. Develop a program to reverse an array using pointer arithmetic.
Reference: T1 Chapter 13, pp. 271-290; T2 Chapter 5, pp. 98-115; R4 Chapter 7, pp. 145-160
7. Arrays and Pointers
Definition: The name of an array acts as a pointer to its first element.
Examples:
1. Accessing Array Elements Using Pointers:
2. int arr[3] = {1, 2, 3};
3. int *ptr = arr;
4. for (int i = 0; i < 3; i++) {
5. printf("%d ", *(ptr + i));
}
6. Array of Pointers:
o Example:
o char *names[] = {"Alice", "Bob", "Charlie"};
printf("%s", names[1]); // Output: Bob
Program from T1 Chapter 13:
#include <stdio.h>
int main() {
char *names[] = {"Alice", "Bob", "Charlie"};
for (int i = 0; i < 3; i++) {
printf("Name[%d]: %s\n", i, names[i]);
}
return 0;
}
Possible Programs:
1. Write a program to find the maximum and minimum elements in an array using pointers.
2. Create a program to sort an array of strings using pointers.
3. Develop a program to copy one array to another using pointers.
Reference: T1 Chapter 13, pp. 290-305; T2 Chapter 5, pp. 115-120
8. Parameter Passing: Pass by Value and Pass by Reference
Pass by Value:
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
A copy of the argument is passed to the function. The original value remains unchanged.
Example:
void changeValue(int x) {
x = 20;
}
int main() {
int a = 10;
changeValue(a);
printf("%d", a); // Output: 10
}
Pass by Reference:
The address of the argument is passed, allowing the function to modify the original value.
Example:
void changeValue(int *x) {
*x = 20;
}
int main() {
int a = 10;
changeValue(&a);
printf("%d", a); // Output: 20
}
Program from T1 Chapter 11:
#include <stdio.h>
void swap(int *x, int *y);
int main() {
int a = 5, b = 10;
printf("Before Swap: a = %d, b = %d\n", a, b);
swap(&a, &b);
printf("After Swap: a = %d, b = %d\n", a, b);
return 0;
}
void swap(int *x, int *y) {
int temp = *x;
*x = *y;
*y = temp;
}
Possible Programs:
1. Write a program to find the sum of two numbers using pass by value.
2. Create a program to find the sum of two numbers using pass by reference.
3. Develop a program to swap two numbers using both pass by value and pass by reference.
Reference: T1 Chapter 11, pp. 265-275; R2 Chapter 5, pp. 130-140
1. Modular Programming
Program: Library Management System (Example of Modular Programming)
#include <stdio.h>
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
// Function prototypes
void addBook();
void viewBooks();
int main() {
int choice;
while (1) {
printf("\nLibrary Management System\n");
printf("1. Add Book\n2. View Books\n3. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1: addBook(); break;
case 2: viewBooks(); break;
case 3: return 0;
default: printf("Invalid choice!\n");
}
}
}
void addBook() {
static int bookCount = 0; // Keeps track of books added
bookCount++;
printf("Book added! Total books: %d\n", bookCount);
}
void viewBooks() {
printf("Feature coming soon!\n");
}
2. Function Prototype, Definition, and Call
Program: Function Prototype Example
#include <stdio.h>
// Function prototype
int add(int, int);
int main() {
int a = 10, b = 20;
printf("Sum: %d\n", add(a, b)); // Function call
return 0;
}
// Function definition
int add(int x, int y) {
return x + y;
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
}
3. Built-in Functions
Program: String and Math Functions
#include <stdio.h>
#include <string.h>
#include <math.h>
int main() {
// String functions
char str1[] = "Hello";
char str2[] = "World";
printf("Length of str1: %lu\n", strlen(str1));
printf("Concatenation: %s\n", strcat(str1, str2));
printf("Comparison: %d\n", strcmp("Hello", "World"));
// Math functions
double num = 16.0;
printf("Square root: %.2f\n", sqrt(num));
printf("Power: %.2f\n", pow(2, 3));
return 0;
}
4. Recursion
Program: Factorial Using Recursion
#include <stdio.h>
int factorial(int n);
int main() {
int num = 5;
printf("Factorial of %d is %d\n", num, factorial(num));
return 0;
}
int factorial(int n) {
if (n == 0) return 1; // Base case
return n * factorial(n - 1); // Recursive call
}
5. Binary Search Using Recursion
#include <stdio.h>
int binarySearch(int arr[], int low, int high, int key);
int main() {
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
int arr[] = {1, 3, 5, 7, 9, 11};
int n = sizeof(arr) / sizeof(arr[0]);
int key = 7;
int result = binarySearch(arr, 0, n - 1, key);
if (result != -1)
printf("Element found at index %d\n", result);
else
printf("Element not found\n");
return 0;
}
int binarySearch(int arr[], int low, int high, int key) {
if (low > high) return -1; // Base case: not found
int mid = (low + high) / 2;
if (arr[mid] == key) return mid; // Found
if (arr[mid] > key) return binarySearch(arr, low, mid - 1, key);
return binarySearch(arr, mid + 1, high, key);
}
6. Pointers
Program: Swap Two Numbers Using Pointers
#include <stdio.h>
void swap(int *a, int *b);
int main() {
int x = 10, y = 20;
printf("Before swap: x = %d, y = %d\n", x, y);
swap(&x, &y);
printf("After swap: x = %d, y = %d\n", x, y);
return 0;
}
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
7. Pointer Arithmetic
Program: Traverse Array Using Pointer Arithmetic
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30, 40, 50};
int *p = arr;
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
printf("Array elements: ");
for (int i = 0; i < 5; i++) {
printf("%d ", *(p + i));
}
printf("\n");
return 0;
}
8. Arrays and Pointers
Program: Access Elements Using Pointers
#include <stdio.h>
int main() {
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int *p = &arr[0][0];
printf("2D Array elements: \n");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
printf("%d ", *(p + i * 3 + j));
}
printf("\n");
}
return 0;
}
9. Array of Pointers
Program: Store and Print List of Names
#include <stdio.h>
int main() {
char *names[] = {"Alice", "Bob", "Charlie"};
for (int i = 0; i < 3; i++) {
printf("Name %d: %s\n", i + 1, names[i]);
}
return 0;
}
10. Parameter Passing
Program: Pass by Value and Pass by Reference
#include <stdio.h>
void passByValue(int a);
void passByReference(int *a);
int main() {
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
int num = 10;
printf("Before pass by value: %d\n", num);
passByValue(num);
printf("After pass by value: %d\n", num);
printf("Before pass by reference: %d\n", num);
passByReference(&num);
printf("After pass by reference: %d\n", num);
return 0;
}
void passByValue(int a) {
a += 10;
}
void passByReference(int *a) {
*a += 10;
}
1. Modular Programming
Company: Infosys (2019)
Program: Library Management System
2. Function Prototype, Definition, and Call
Company: TCS (2021)
Program: Function Prototype Example
3. Built-in Functions
Company: Capgemini (2020)
Program: String and Math Functions
4. Recursion
Company: Amazon (2017)
Program: Factorial Using Recursion
5. Binary Search Using Recursion
Company: Google (2016)
Program: Binary Search Function
6. Pointers
Company: Accenture (2020)
Program: Swap Two Numbers Using Pointers
7. Pointer Arithmetic
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C
Company: Wipro (2018)
Program: Traverse Array Using Pointer Arithmetic
8. Arrays and Pointers
Company: TCS (2022)
Program: Accessing 2D Array Elements Using Pointers
9. Array of Pointers
Company: Amazon (2014)
Program: Store and Print List of Names
10. Parameter Passing
Company: Microsoft (2016)
Program: Pass by Value and Pass by Reference
Academic Year 2024-2025(Even Semester)
CS3251-PROGRAMMING IN C