how to carry on answer

just a quick question about a code I have. hopefully ill be able finish the rest of the code myself after this. I have this code multiply the number I enter by 9 and giving me an answer, how can I carry on this answer to carry out another calculation in the same code, basically I want to add all the numbers up in the answer apart from the last one, I can do this in a different code but I don't no how to join it up to this one.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 #include <stdio.h>
#include <iostream>
using namespace std;
void calc(int);

int main()
{
int num;
printf("enter 3 diget number above 0:\n");
scanf("%i", &num);
calc (num);

    return 0;
}

void calc (int n)
{
	n=n*9;
	printf("the enterd number multiplyed by 9 id %i\n",n);
	return;

}


void calc (long)
{
return;
}


this is the code I have to add up all the numbers apart from last one,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <conio.h>

int main()
{
  int num;
  int sum = 0;
  printf(" Enter a number above 0 : ");
  scanf("%d", &num);
  num /= 10;
  while (num > 0)
  {
    sum += num % 10;
    num /= 10;
  }
  printf("Sum = %d", sum);

  getch();

  return 0;
}
Topic archived. No new replies allowed.