What value is returned by the function result below int resu

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 largest of first n elements of array a The value of the largest of the first n elements of array a The subscript of the smallest of the first n elements of array a The value of the smallest of the first n elements of array a The subscript of the last element greater than its predecessor within the first n elements of array a How many lines of output will be displayed by the following program fragment? for(i = 0; i

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site