simple program

"Write a program that keeps prompting user for an integer. Upon an input of 0, the program will show the first 5 (if not, lesser) unique integers entered."
i can't seem to get my codes to work. any help pls?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
using namespace std;

int absolute(int v); //OR use abs() predefined function from cstdlib
void printAscendingTriangle(int input);
void printPattern(int input);
void printDescendingTriangle(int input);

void main(void)
{
	int input;

	cout << "Input an integer: ";
	cin >> input;

	if(input > -3 && input < 3)
	{
		cout << "Invalid range." << endl;
	}
	else if(input % 2 == 0)
	{
		cout << "Odd integers only." << endl;
	}
	else
	{
		printAscendingTriangle(absolute(input));
		printPattern(input);
		printDescendingTriangle(absolute(input));
	}
}


first of all never use the main function as void it is is ALWAYSint secondly you only prompt once. You should try a do/while or while loop to ask the user for their input until 0 is entered. As far as the assignment goes I am assuming that is only part of it because you are doing something with triangle output and the assignment just asks for a loop of inputs then on input of 0 the program will display the first 5 if not lesser unique ints.
Topic archived. No new replies allowed.