answersLogoWhite

0

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

12y ago

What else can I help you with?

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 an arithmetic operator that multiplies?

Multiplication


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 arithmetic operator multiplies by 0.01?

percentage


Arithmetic operator that 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