Changing Array Inside Function in C Last Updated : 03 Nov, 2022 Comments Improve Suggest changes Like Article Like Report When declaring an array the array name is always called the pointer because in an array name the address of the 0th block(base address) is stored. To change an array in the function we have to pass an array in the function. For this, an array_name is passed to the function in the form of an actual argument. So an address of the 0th block pass to the function call as an actual argument and this address passes to the formal argument in the function to define the body. When an array passes in the function then an original array passed in it. Since an array is passing by reference(address). Then if any changes occur in an array in the form of a formal argument inside the function define body then the implemented changes also occur in an array which define in the main(). Example 1: C // C Program to change an Array in function #include <stdio.h> // here 'm' is the formal argument void addval(int m[]) { int i; for (i = 0; i < 5; i++) { // adding 10 value to each element // of an array m[i] = m[i] + 10; } } // here 'm' is the formal argument void dis(int m[]) { int i; for (i = 0; i < 5; i++) { printf("%d ", m[i]); } printf("\n"); } void main() { int a[] = { 11, 12, 13, 14, 15 }; printf("Array before function call\n"); // function call dis(a); // calling addval function addval(a); printf("Array after function call\n"); dis(a); } OutputArray before function call 11 12 13 14 15 Array after function call 21 22 23 24 25 Example 2: C // C Program to take name as input // and change it in function #include <stdio.h> #include <string.h> // function definition body // n is the formal argument void change_upper(char* n) { for (int i = 0; n[i] != '\0'; i++) { if (n[i] != ' ') { // changing the case from // lower to upper case n[i] = toupper(n[i]); } } } void main() { char name[50]; printf("Enter the Name :\n"); gets(name); printf("The name is %s\n", name); // function call passing an array "name" // in the function change_upper(name); printf("The name after calling the function is %s\n", name); } Output: Enter the Name : GeeksForGeeks The name is GeeksForGeeks The name after calling the function is GEEKSFORGEEKS Comment More infoAdvertise with us Next Article Changing Array Inside Function in C R rajjma3cs Follow Improve Article Tags : C Language Similar Reads Pass Array to Functions in C Passing an array to a function allows the function to directly access and modify the original array. In this article, we will learn how to pass arrays to functions in C.In C, arrays are always passed to function as pointers. They cannot be passed by value because of the array decay due to which, whe 3 min read User-Defined Function in C A user-defined function is a type of function in C language that is defined by the user himself to perform some specific task. It provides code reusability and modularity to our program. User-defined functions are different from built-in functions as their working is specified by the user and no hea 6 min read C++ Function Call By Pointer Several ways exist in which data (or variables) could be sent as an argument to a function. Two of the common ones are Passing by Value and Passing by Reference. Example: C++ // C++ Program to demonstrate // Pass by value and // Pass by reference #include <iostream> using namespace std; // Pas 3 min read Nested Functions in C Nesting of functions refers to placing the definition of the function inside another functions. In C programming, nested functions are not allowed. We can only define a function globally.Example:C#include <stdio.h> int main() { void fun(){ printf("GeeksForGeeks"); } fun(); return 0; }Outputmai 4 min read Function Pointer in C++ Prerequisites: Pointers in C++Function in C++ Pointers are symbolic representations of addresses. They enable programs to simulate call-by-reference as well as to create and manipulate dynamic data structures. Iterating over elements in arrays or other data structures is one of the main use of point 4 min read Function Pointer in C In C, a function pointer is a type of pointer that stores the address of a function, allowing functions to be passed as arguments and invoked dynamically. It is useful in techniques such as callback functions, event-driven programs, and polymorphism (a concept where a function or operator behaves di 6 min read Function Calling in Programming Function Calling in programming refers to the process of invoking or executing a function within a program. Functions are blocks of code that perform a specific task, and they allow programmers to organize their code into reusable units, making it easier to manage and maintain. Table of Content What 4 min read main Function in C The main function is the entry point of a C program. It is a user-defined function where the execution of a program starts. Every C program must contain, and its return value typically indicates the success or failure of the program. In this article, we will learn more about the main function in C.E 5 min read round() Function in C In the C language, the <math.h> header file contains the Standard Math Library that provides various mathematical functions, including the round() function. In this article, we will see how to use the round() function in C.What is round() in C?C round() is a built-in library function that roun 3 min read rename function in C The rename() function is used to rename a file in C. It changes the name of the file from old_name to new_name without modifying the content present in the file. It is defined inside <stdio.h> header file. In this article, we will learn how to rename a file using the rename() function in C pro 2 min read Like