@thepriyablog
The fifth line in your code has error. There is a syntax error in your “for loop”. There should be a semicolon after the condition i<one;
But you have comma after the condition.
Well, there are some syntax error with your for loop, can you try below code to fix the error you are getting.
#include <stdio.h>
int main() {
int one, two, three, sum = 0;
// Prompt the user to enter a number
printf("Enter a number: ");
scanf("%d", &one);
// Corrected the loop syntax
for (int i = 1; i < one; i++) {
// Resetting 'two' and 'three' at the beginning of each iteration
two = 0;
three = i;
// Incorrect logic for accumulating sum
sum = sum + two;
// Incorrect placement of printf, should be outside the loop if you want to print the sum
// Also, consider adding a newline character '\n' to make the output readable
printf("%d ", sum);
}
// Corrected the placement of printf if you want to print the sum after the loop
printf("\nTotal sum: %d\n", sum);
return 0;
}