The name of your C program file must be called triangular1.c, files with any other name will not be marked.
1 + 2 + 3 + ... + n
for some natural number n. The sequence of triangular numbers for n = 1, 2, 3... is:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Keep prompting the user to enter an integer until the user chooses to quit the program by entering a value of 0. When the user quits the program, display the number of integers entered, as well as the number of triangular and non-triangular numbers.
$ gcc -Wall triangular1.c -o triangular1 $ ./triangular1 Enter an integer (1 - 2000000000, 0 to quit): 1 1 is a triangular number. Enter an integer (1 - 2000000000, 0 to quit): 2 2 is between triangular numbers 1 and 3. Enter an integer (1 - 2000000000, 0 to quit): 97 97 is between triangular numbers 91 and 105. Enter an integer (1 - 2000000000, 0 to quit): 45 45 is a triangular number. Enter an integer (1 - 2000000000, 0 to quit): 46 46 is between triangular numbers 45 and 55. Enter an integer (1 - 2000000000, 0 to quit): 1999996635 1999996635 is a triangular number. Enter an integer (1 - 2000000000, 0 to quit): 2000000000 2000000000 is between triangular numbers 1999996635 and 2000059881. Enter an integer (1 - 2000000000, 0 to quit): 0 Number of integers entered: 7 Triangular numbers: 3 Non-triangular numbers: 4 Thank you for using my program. Goodbye! $
A total of 18 different hosts have accessed this document in the last 445 days; your host, nsrp-source.comp.nus.edu.sg, has accessed it 7 times.
If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.