How can I use a single while loop to restrict entry of negative integers to the code. I have previously tried with two while loops each for the two scanf() and works cool. But I am unable to figure our how to combine them into one while loop. I have removed the two while loops I have originally used. I am completely new to this and I need some ideas.
#include <stdio.h>
int main()
{
int num, uplimit, a;
printf("Which multiplication table do you want? ");
scanf("%d",&num);
printf("Please enter the upper limit: ");
scanf("%d",&uplimit);
printf("\nMultiplication Table for %d\n", num);
printf("===========================\n\n");
for(a=1;a<=uplimit;++a)
{
printf( "%d X %d = %d %s\n", a, num, num*a, (num*a % 2 == 0) ? "*" : " " );
}
{
printf("\n* indicates even multiple of %d", num);
}
return 0;
}