GATE Exam  >  GATE Questions  >  Consider the following functionint BSR (int a... Start Learning for Free
Consider the following function
int BSR (int arr[ ], int k)
{
int val=0, i, last;
for(i=0;i<k;i++)
value +=arr[i];
last =(k*(k-1))/2;
return (value-last);
}
Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?
  • a)
    Sum of all numbers
  • b)
    Repeated number in listCorrect Answer
  • c)
    Average of all numbers
  • d)
    None of these.
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
Consider the following functionint BSR (int arr[ ], int k){int val=0, ...
This program finds a repeated number (duplicate) in the list. This program adds all values in the variable “ value” and substract “k(k-1)2” from it.Array has 0 to (k-1) locations and numbers are from 1 to (k-1).so one number will be repeated in the array.
View all questions of this test
Most Upvoted Answer
Consider the following functionint BSR (int arr[ ], int k){int val=0, ...
The given function is incomplete as it is missing the rest of the code. Could you please provide the complete code for the function?
Explore Courses for GATE exam
Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer?
Question Description
Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer?.
Solutions for Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer?, a detailed solution for Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the following functionint BSR (int arr[ ], int k){int val=0, i, last;for(i=0;i<k;i++)value +=arr[i];last =(k*(k-1))/2;return (value-last);}Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?a)Sum of all numbersb)Repeated number in listCorrect Answerc)Average of all numbersd)None of these.Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev