ok below is a sample program I used to
multiple 2 numbers the numbers can be
more than 1 digit,. I know its long winded
and the functions are not needed but I was
just trying to get to grips with different
things as im used to delphi. the program
has one problem when it asks if you want
to try again the program ends and does not
wait for input, im guessing there is still
something in the input buffer. Can you
have a look and tell me how this could be
fixed and if theres anyhting else I should
have done different? code exmaples would be
great.
Thanks.
Code:
#include <stdio.h>
int intAnswr(int,int);
char chrRpt (int);
int main ()
{
int intN1,intN2;
int intFst;
intN1 = 0;
intN2 = 0;
intFst = 0;
while (chrRpt(intFst) == 'Y')
{
intFst = 1;
printf ("\nEnter First No. : ");
scanf ("%d",&intN1);
printf ("Enter Second No. : ");
scanf ("%d",&intN2);
printf ("\n%d * %d = %d\n",intN1,intN2,intAnswr(intN1,intN2));
}
}
char chrRpt(int intRun)
{
char chrTmp='Y';
if (intRun != 0)
{
printf("Try Again? Y/N");
scanf ("%c",&chrTmp);
}
return (chrTmp);
}
int intAnswr(int n1,int n2)
{
return(n1 * n2);
}