answersLogoWhite

0


Best Answer

Arithmetic operators take two inputs, one on either side of the operator. For instance, to add two numbers, say 2 and 5, either of the following expressions will work:

2+5

5+2

The result from this expression is "7", which must be used either in a function or variable assignment as follows:

int i=2+5;

This will not only declare variable "i", but initialize it to a value of "7".

For getting input from the user that can be used with arithmetic operators, the method will depend upon the interface you're using. If you're writing a console (text-only) application, scanf() and atoi() will work nicely:

int main()

{

int num1, num2;

printf("Enter the first number: ");

scanf("%d", num1);

printf("Enter the second number: ");

scanf("%d", num2);

printf("%d + %d = %d\n", num1, num2, num1+num2);

return 0;

}

Here, scanf() is used to read input from the user into two numbers. Then those two numbers are printed as well as the result of adding both of them.

See the related link below for more information on scanf() to read user input. If you're writing a graphical application, look on the Web for tutorials for the compiler (and supporting library) you're using to write your program.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you get input for an arithmetic operator in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is precedence between relational operator and arithmetic operator?

Arithmetic operators (+, -, *, /, % ) have greater precedence over relational operators (<, >, <=, >=, ==, !=) in C language.


C program to implement arithmetic assignment operator?

y=2x2+3x+1


Input output function in c plus plus?

input is the << operator and output is the >> operator


Which arithmetic operator have highest precedence?

In all popular high-level programming languages, the order in which operators are interpreted ("operator precedence") is vital to ensuring that all compilers execute instructions in precisely the same manner, as the "order of operations" rule is vital in mathematics. In the case of C and C++, arithmetic operators are executed prior to logic operators. For a detailed description of operator precedence, see the related links below.


What is the extraction operators in C plus plus?

This operator (>>) applied to an input stream is known as extraction operator. It performs an input operation on a stream generally involving some sort of interpretation of the data (like translating a sequence of numerical characters to a value of a given numerical type).Three groups of member functions and one group of global functions overload this "extraction operator" (>>) applied to istream objects:The first group of member functions are arithmetic extractors. These read characters from the input data, and parse them to interpret them as a value of the specific type of its parameter. The resulting value is stored in the variable passed as parameter.The streambuf version copies as many characters as possible to the stream buffer object used as right-hand parameter, either until an error happens or until there are no more characters to copy.Those in the last group of member functions have a pointer to a function as parameter. These are designed to be used with manipulator functions. Manipulator functions are functions specifically designed to be easily used with this operator.The global functions overload the operator when the parameter is either a character or a c-string, and, as expected they extract either one character or a sequence of characters from the input stream.

Related questions

What is an arithmetic operator in c?

+


What is an arithmetic operator in c program?

An arithmetic operator is any of the "atomic" operators to do the following math operations: + addition - subtraction / division * multiplication % modulus division


What is precedence between relational operator and arithmetic operator?

Arithmetic operators (+, -, *, /, % ) have greater precedence over relational operators (<, >, <=, >=, ==, !=) in C language.


C program to implement arithmetic assignment operator?

y=2x2+3x+1


Input output function in c plus plus?

input is the << operator and output is the >> operator


Arithmetic operator that divides contents of a cell?

The arithmetic operator that divides contents of a cell is the front slash. =A3/B3


What is stream operator in c plus plus?

There are two stream operators: << (insert or put) and >> (extract or get). Output streams implement the insertion operator, input streams implement the extraction operator and input/output streams implement both operators.


What is an arithmetic operator that multiplies?

Multiplication


Arithmetic operator that multiplies by 0.01?

percentage


What arithmetic operator multiplies by 0.01?

percentage


Which arithmetic operator have highest precedence?

In all popular high-level programming languages, the order in which operators are interpreted ("operator precedence") is vital to ensuring that all compilers execute instructions in precisely the same manner, as the "order of operations" rule is vital in mathematics. In the case of C and C++, arithmetic operators are executed prior to logic operators. For a detailed description of operator precedence, see the related links below.


Arithmetic operator that makes a number negative?

Negation