Entering variables with serial communication

Does anyone know how to do something equivalent to this with serial communication?

#include <stdio.h>

int main(void)
{
int number1, number2;

printf("Please input an integer value: ");
scanf("%d", &number1);
printf("Please input an integer value: ");
scanf("%d", &number2);

printf("%d + %d = %d\n", number1, number2, number1 + number2);
return 0;
}

Hi N3R0, welcome to the forum.

There is not enough context to your question to provide a good answer. There are many ways of doing what you want depending on what is at the other end of the serial port, the range of value you want to accept and how much error handling you want to provide.

Can you say a little more about what your application needs to do and what it will connect to.

Sorry,
I am trying to figure out how to set variables while the program is running on the arduino using serial communication. I have an arduino hooked up to a servo, and I am trying to input the position using the serial monitor. The problem that I have is if I enter the number 8 and the program sets the variable like this...
number = Serial.read();
It won't set the variable as 8 but the number 56 that is assigned to 8.
What command will recognize the number I input?
Also, if I input a number higher than 9 like 700, it will only recognize the number as 55, 48, 48.

There is an example showing how you can do this in the playground: Arduino Playground - Servo

I am trying to figure out how to set variables while the program is running on the arduino using serial communication.

This seems like a natural fit for MRMP...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232140631