Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 What will be the output of the program ? #include<stdio.h> int main() { void fun(int, int[]); int arr[] = {1, 2, 3, 4}; int i; fun(4, arr); for(i=0; i<4; i++) printf("%d,", arr[i]); return 0; } void fun(int n, int arr[]) { int p=0; int i=0; ?->(Show Answer!)
1. What will be the output of the program ? #include<stdio.h> int main() { void fun(int, int[]); int arr[] = {1, 2, 3, 4}; int i; fun(4, arr); for(i=0; i<4; i++) printf("%d,", arr[i]); return 0; } void fun(int n, int arr[]) { int p=0; int i=0; while(i++ < n) p = &arr[i]; p=0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.00 pm
Step 1: void fun(int, int[]); This prototype tells the compiler that the function fun() accepts one integer value and one array as an arguments and does not return anything. Step 2: int arr[] = {1, 2, 3, 4}; The variable a is declared as an integer array and it is initialized to a[0] = 1, a[1] = 2, a[2] = 3, a[3] = 4 Step 3: int i; The variable i is declared as an integer type. Step 4: fun(4, arr); This function does not affect the output of the program. Let's skip this function. Step 5: for(i=0; i<4; i++) { printf("%d,", arr[i]); } The for loop runs untill the variable i is less than '4' and it prints the each value of array a. Hence the output of the program is 1,2,3,4