What value is returned by the function result below int resu
Solution
1)
#include<stdio.h>
#include<conio.h>
int result(int a[], int size) {
int i,r;
r=0;
for (i = 0; i < size; ++i) {
if(a[i]>a[r])
{
r=i;
}
}
return r;
}
int main()
{
int balance[10] = {656, 656, 656, 50, 5,256,314,656,656,1};
/* pass pointer to the array as an argument */
int k = result( balance, 10 ) ;
/* output the returned value */
printf( \"subscript value is: %d \", k );
return 0;
}
output
0
answer: A
2)
int main()
{
int i,j;
for(i=0;i<=5;i++)
{
for(j=0;j<i;j++)
{
printf(\" %d %d\ \",i,j);
}
}
return 0;
}
output
1 0
2 0
2 1
3 0
3 1
3 2
4 0
4 1
4 2
4 3
5 0
5 1
5 2
5 3
5 4
4)solution
d)15
5)
While passing exhibits arrays as parameter to the method/functon, just the name of the array is passed (,i.e, beginning location of memory region is passed as argument or starting address of memory area is passed as argument to that function)
![What value is returned by the function result below: int result (in a[], int n) {int i, r; r = 0; for (i = 1; i a[r]) r = i; return (r);} The subscript of the What value is returned by the function result below: int result (in a[], int n) {int i, r; r = 0; for (i = 1; i a[r]) r = i; return (r);} The subscript of the](/WebImages/19/what-value-is-returned-by-the-function-result-below-int-resu-1040184-1761540195-0.webp)
![What value is returned by the function result below: int result (in a[], int n) {int i, r; r = 0; for (i = 1; i a[r]) r = i; return (r);} The subscript of the What value is returned by the function result below: int result (in a[], int n) {int i, r; r = 0; for (i = 1; i a[r]) r = i; return (r);} The subscript of the](/WebImages/19/what-value-is-returned-by-the-function-result-below-int-resu-1040184-1761540195-1.webp)