Find the output of the below program.
#include <stdio.h>
int main()
{
int arr[] = { 9.1.7.5, 5, 6,-1, 5, 1, 2 };
int count = 0. sum = 11. n = 10;
for (int i = 0; i<n; i = i + 2)
{
for (int j = i + 1;j<n; j++)
{
if (arr[i] + arr[i] == sum)
{
count += count++;
}
1
1
printf("%d", count):
}
Answers
Answered by
10
x(2+
3
1
)=35
→x(
3
7
)=35
→x=35×
7
3
→x=
7
105
⇝
★x=15★
Answered by
1
The output of the algorithm is "2"
Explanation:
#include <stdio.h>
int main()
{
int arr[] = {9,1,7,5, 5, 6, -1, 5, 1, 2};
int count = 0, sum = 11, n = 10;
for (int i = 0; i < n; i = i + 2)
{
for (int j = i + 1; j < n; j++)
{
if (arr[i] + arr[j] == sum)
{
count++;
}
}
}
printf("%d", count);
}
The above algorithm is a c program to find the number of pairs in a given array whose sum that is equal to the sum=11
such that the first number of the pairs are in the even place and second number of the pair is any number after the first number
Hence, the output of the above algorithm is 2
Similar questions