Computer Science · C Programming
What is the following code segment determining? int recipe(int a){ int n = a << 2; return (n % 2 == 0 ? 1 : 0); } int secret(int a[], int n){ int s = 0, i; for (i = 0; i < n; i++) if (recipe(a[i])) s += a[i]; return s; } int main() { int a[] = {1, 2, 3, 4, 5}; printf('%d', secret(a, 5)); }
- 1The program is finding the sum of only the even numbers in the array
- 2The program is finding the sum of the even-indexed array elements
- 3The program is finding twice the sum of the array elements
- 4The program is finding the sum of all elements in the array✓
Correct answer
The program is finding the sum of all elements in the array
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on C Programming?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · C Programming