This code is meant to ask for an integer input from the user, then confirm if it is the input, and then display whether it is positive or negative if the answer is 'yes'.
#include<stdio.h>
int main()
{
int s;
printf("Enter an integer:");
scanf("%d", &s);
printf("So, you entered %d\n", s);
printf("Is that correct? (y/n)\n");
char chr;
scanf("%c", &chr);
if(chr=='y')
{
if (s<0)
{
printf("\n%d is a negative number.\n", s);
}
else if(s==0)
{
printf("\nThe number which you entered is Zero\n");
}
else
{
printf("\n%d is a positive number\n", s);
}
}
else if(chr=='n')
{
printf("\nSorry, for that. Please re-execute this program.\n");
}
else
{
printf("\nEnter the write keyword! Re-execute this program.\n");
}
return 0;
}
But this doesn't ask for any input during the char
scanf
.
Syntax error, or something else?