Computer Science, asked by Kg4571, 8 months ago

int f (int n) { int ans = 0; for (int i = 1; i < n; i++) { if (i < n/2) { ans -= i; } else { ans += i; } } return ans; } what is f(7)

Answers

Answered by BLANKBABA
1

Answer:

number is 15

please mark me brianliest

Explanation:

#include<stdio.h>

int f (int n) {

int ans = 0;

for (int i = 1; i < n; i++) {

if (i < n/2) {

ans -= i;

}

else {

ans += i;

}

}

return ans;

}

int main()

{

printf("Numbers are %d",f(7));

return 0;

}

Similar questions