hi there I'm new to programing so sorry about the questions as I no there basic steps. but I just cant figure it out. I have wrote two pieces of codes now I wish to join them up, at the moment I have one code that will multiply the number I enter by 9 and give me the answer. and I have another code that will add up all the numbers I enter apart from the last one. what I wish to do is join the two codes. so when I enter a number it will multiply it by 9, then adds up all the numbers in the answer apart from the last one and gives me the answer. can anyone show me how to do this as iv spent hours and hours trying it but cant get it to work. hear are the two codes I have
Code:
#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;
}
and the second one
Code:
#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;
}
if anyone can help me it would be great, thanks in advance