How to do this function once the decrement becomes less that zero example below C++?

Once this function becomes lower than zero how can I make so it decrement minuses from 256
EXAMPLE
5 -5 = 0 after this i want the program to
256 -5 = 251
251-5 = 246

so output should equal 0,251,246



int inp = 5;
int v1 = -5;
int v2= 3;
int a1 = inp+v1;
int a2 = inp + ( v1 * v2 );
int i;
for ( i=a1 ; i>=a2 ; i+= v1 ) {
cout<< i << endl;
}
Last edited on
It is strange enough that the results

5 -5 = 0 after this i want the program to
256 -5 = 251
251-5 = 246

shall be displayed as

0,250,245
Last edited on
it should be 0,251,246 typo
For example it can be done the following way

1
2
3
4
unsigned char c = 5; 
for ( unsigned char i = 0; i < 3; i++  ) 
	std::cout << int( unsigned char( - i * c ) ) << ' ';
std::cout << std::endl;
Topic archived. No new replies allowed.