//To print the multiplication table of a number upto an upper bound //@author-Karan Narain(karan@iitk.ac.in) #include int main() { int a,b,i,product; /*The while loop below is included to satisfy the requirement that the inputs need to be positive.The while loop keeps repeating till the user enters valid inputs.To enter into this while loop the first time,we initialize a to an illegal value(-1).We maintain a counter i which counts the number of times the user has entered values and display a message accordiingly*/ a=-1; i=0; while(a<=0||b<=0) { //This is the first time the user is entering values if(i==0) printf("\nPlease enter two positive values of a and b\n"); //The user had entered incorrect values.Print appropriate message else printf("Both the values need to be positive.Please enter proper values\n"); scanf("%d %d",&a,&b); i++; } product=a; i=1; while(product<=b) { printf("%d * %d = %d\n",i,a,product); i++; product=a*i; } return 0; }