Write isTriangular function, which takes a positive integer and returns 1 if the given number is a triangular number; returns 0, otherwise.
The main function is okay, but there is some errors in "isTriangular" function which i can not see, please help me.Triangular numbers are shown below:
int isTriangular(int N)
int sum = 0, n = 0;
for (n; sum <= N; n++)
sum += n;
if (sum == N)
if (x > 0)
printf("%d is a triangular number\n", x);
printf("%d is NOT a triangular number\n", x);
while (x > 0);
Change termination condition from
sum <= N to
sum < N.