Help

Someone help me with this, I am getting errors. Which part is wrong?
Program is supposed to check if the input number is 2 digit or 1 digit.

if 1 digit = return to its own
if 2 digit = add both the 1st digit and 2nd second together.


int checkDoubleDigit(int n)

{
int no1, no2;

if (n > 9);
n = no1;

else
(n > 10);
no1 = (n / 10);
no2 = no1 + (n % 10);

}


I also need some help from someone viewing my whole code, I mean I really need someone to help me out. I am helpless in school and I am trying hard. Please pm me if you are free and would like to offer me some help :) Thank you for reading.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int checkDoubleDigit(int n)

{
int no1, no2;

if (n <= 9)      //no semicolon after condition of if-statement
{
no1 = n;      //needs to be put between braces and turned around because you can't give n the value of no1
}
else             //an else-statement doesn't need any conditins, take else if( condition )  if you need to check sth.
{
no1 = (n / 10);
no2 = no1 + (n % 10);
}

}


I'd say you really need to have a look at the reference and/or get a beginners guide else you'll most likely get huge problems in school.
Last edited on
Thanks Hughes! Really appreciate your help on this.
No problem, I just noticed a small mistake I didn't see yesterday, but it is fixed now (in the code in my previous answer).
Yeah it didn't work previously and I was struggling to make it work. Thanks again man :) It works fine now and I can continue with my assignment!
Topic archived. No new replies allowed.