QUESTION: Take any 4 integers add them and print the first and last digit of the answer the restriction is that i can only use scanf command and data types..

You need to ask questions about your program, rather than posting your assignment and saying "thanks" for the solution.

It is your assignment, after all. You won't learn by not working with it.

And Welcome to the Forum, Ahmed! ;)

Edited 6 Years Ago by Adak: n/a

thanks bro for replying i have made the prog but i totally stuck at the situation that how can i print first and last digit of the answer..

If you have a number in base 10 (normal base), and use the mod operator on it, what do you get?

int number = 123;
printf("\n %d", (number % 10));

now divide the number by 10. You've now "peeled off" the right most digit from the number.

You can continue doing this in a loop, until the number disappears. Save the first and the last digit, and there you go.

If you need any more help with your program, post your code so we can see the details of what you're referring to. Doesn't have to be the whole program, but at least the part you're referring to.

AND do use code tags around any posted code - please!

Edited 6 Years Ago by Adak: n/a

This question has already been answered. Start a new discussion instead.