This is my code for incrementing either positively or negatively but somehow the code compiles but dosen't work.
#include <cs50.h>
#include <stdio.h>
int main()
{
int Ini, Con, Incre;
//ask user for input
printf("Initialization: \n");
scanf("%d", &Ini);
printf("Condition: \n");
scanf("%d", &Con);
printf("Increment: \n");
scanf("%d", &Incre);
//how to increment variable
char PN = '\0';
{
printf("\nPositive or Negative increment?\n");
PN = GetChar();
int count = 0;
{
if(PN == 'P' || PN == 'p')
{
for(count = Ini; count < Con; count = (count + Incre));
printf("%d\n", count);
}
else if(PN == 'N' || PN == 'n' )
{
for(count = Ini; count > Con; count = (count - Incre));
printf("%d\n", count);
}
}
}
}
And this is what it compiles
/home/ubuntu/workspace/fooling/ $ make counter clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow counter.c -lcs50 -lm -o counter /home/ubuntu/workspace/fooling/ $ ./counter Initialization: 2 Condition: 30 Increment: 5
Positive or Negative increment? Retry: p 32 /home/ubuntu/workspace/fooling/ $
can you tell me where i went wrong?