#include<stdio.h>
int get_sum(int n)
{
int sm, i;
for(i = 1; i <= n; i++)
sm += i;
return sm;
}
int main()
{
int n = 10;
int ans = get_sum(n);
printf("%d",ans);
return 0;
}
Answer: D
Explanation: Since the variable “sm” is not initialized to 0, it will produce a garbage value. Some compiler will automatically initialises variables to 0 if not initialised. In that case the value is 55. Hence the value depends on the compiler.