hi there I'm at this code here for the last couple of days and final after getting it working. it only problem I keep getting is my text at the end keeps repeating its self, when I press 1 to repeat the code, the same text comes up twice, and after this it will come up with 3 lines if there's 3numbers in the number entered, or 4 lines if 4 numbers are entered, can anyone see where my problem is coming from? thanks in advanced
#include <stdio.h>
int main ()
{
int removelastnumber, number, mvalue, i, sumnumber=0, next , finalnumber;
char choice;
do
{
sumnumber = 0;
do
{
printf ("Enter number above zero\n");
scanf("%d",&number);
}
while (number<0 ); // number has to be greather then zero
mvalue = number*9; // multiply by 9
removelastnumber = mvalue/10; // removes last number
while (removelastnumber > 0) // must be greather then zero
{
sumnumber += removelastnumber % 10;
removelastnumber = removelastnumber/10;
}
for (i=0; i < sumnumber + 9; i += 9)
{
next = i;
}
finalnumber =next - sumnumber;
printf("The last digit of the integer entered %d multiplied by 9 is %d\n " ,number, finalnumber );
getchar();
do
{
printf("To go again press 1:\n");
scanf("%c", &choice);
}
while(choice != 'Y' && choice != 'y' && choice != 'N' && choice != 'n');
}
while(choice=='Y'||choice == 'y');
printf("To exit program press 2\n");
return 0;
}
I managed to sort some of this, only problem I have now is i what the program to exit when i press 2,
but at the moment when i press two i get two lines of code saying "to go again press1"