int v1 = atoi(argv[1]);
int v2= atoi(argv[2]);
int i ;
int input =100;
int a1 = input+v1;
int a2 = input + ( v1 * v2 );
int a3 = input-v1;
int a4 = input - ( v1 * v2 );
______________________________________
if(v1<0)
{
for ( i=a3; i>=a4 ; i-= v1 )
{
cout << i << "\n"; <---- what's wrong with this
when v1 is a negative no.
it's suppose decrement
}}
___________________________________________
for ( i=a1 ; i<=a2 ; i+= v1 )
{
cout << i << "\n";
}
system("PAUSE");
return 0;
}
When v1 is negative then it can be that int a4 = input - ( v1 * v2 ); is positive and greater than int a3 = input-v1;. For example let assume that v1 = -1 and v2 = 2. In this case a4 = 102 and a3 = 101. So the loop will be never executed
1 2 3 4 5
if(v1<0)
{
for ( i=a3; i>=a4 ; i-= v1 )
{
cout << i << "\n";
when v1 is a negative no.
it's suppose decrement
}}