im trying to get my code to display the amount of numbers that are in the answer to the first calculation. i want to display this at the end of the program, but when i try to modify the code to get it to do this i eader get heaps of errors that i cant solve or the code will compile and stop to work. can any one point me in the right direction on how to get this working please?
this is the original code
#include <stdio.h>
int main ()
{
int removelastnumber, number, mvalue, i, sumnumber=0, next , finalnumber;
char choice;
{
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) // greather then zero
{
sumnumber += removelastnumber % 10;
removelastnumber = removelastnumber/10; //devide my 10 again
}
for (i=0; i<sumnumber+9;i+=9) //multiplication of 9 closes to sum
{
next = i;
}
finalnumber=next-sumnumber;
printf("The last number enterd %d multiplied by 9 is %d\n " ,number, finalnumber ); //gives out the wanted number
getchar();
do
{
printf("To go again press 1\n"); // send back to start
printf("To exit program press 2\n"); // exits program
scanf("%c", &choice);
}
while (choice == '1' && choice != '2');
while (choice == '1');
}
return 0;
}
#include <stdio.h>
#include <conio.h>
int main ()
{
int removelastnumber, number, mvalue, i, sumnumber=0, next , finalnumber;
char choice;
{
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
while (number > 0);
sumnumber += number % 10;
number /= 10;
removelastnumber = mvalue/10; // removes last number
while (removelastnumber > 0) // greather then zero
{
sumnumber += removelastnumber % 10;
removelastnumber = removelastnumber/10; //devide my 10 again
}
for (i=0; i<sumnumber+9;i+=9) //multiplication of 9 closes to sum
{
next = i;
}
finalnumber=next-sumnumber;
printf("Sum = %d", sumnumber);
printf("The last number enterd %d multiplied by 9 is %d\n " ,number, finalnumber ); //gives out the wanted number
getchar();
do
{
printf("To go again press 1\n"); // send back to start
printf("To exit program press 2\n"); // exits program
scanf("%c", &choice);
}
while (choice == '1' && choice != '2');
while (choice == '1');
}
return 0;
}