Arrays - Find Output of Program :: Discussion


2.What will be the output of the program?
A.2, 3, 4, 5
B.1, 2, 3, 4
C.0, 1, 2, 3
D.3, 2, 1 0
Answer:  Option  B
Explanation:

Step 1void 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 2int 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 3int i; The variable i is declared as an integer type.

Step 4fun(4, arr); This function does not affect the output of the program. Let's skip this function.

Step 5for(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

Tutorial Link:
Published by:Michael Daani

Comments are not available

Post your comments here:

Optional

Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers