Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
44 views
in Computer by (44.8k points)
closed by

Math Operations in Programming.

1 Answer

+1 vote
by (44.9k points)
selected by
 
Best answer

We have understood how to declare and initiate a variable and how to validate the user input let us now understand how we can perform mathematical operations of these variables. 

In programming, there are following operations that you can perform on variables.

Addition Addition operation is used to perform mathematical addition of two variables. In programming, we refer to “+” as a symbol of addition. Please note that Addition can only be carried out on Integer, Float, Double and String datatypes only. You can use this operator to concatenate two strings on either side of the operator. 

For example, if there are two float variables, “x” and “y” declared in your program. Where x = 1.1, and y = 2.2. If we perform addition operation these variables in programming, the result is going to be 3.3

Subtraction 

Subtraction operation is used to perform mathematical subtraction of two variables. In programming, we refer to “-” as a symbol of subtraction. Please note that subtraction can only be carried out on Integer, Float, Double datatypes only.

For example, if there are two integer variables “a” and “b” declared in your program. Where a = 3, and b = 2. If we perform the subtraction operation of these variables in programming, the result is going to be 1.

Multiplication 

Multiplication operation is used to perform the mathematical multiplication of two variables. In programming, we refer to “*” as a symbol of multiplication. Please note that multiplication can only be carried out on Integer, Float and Double datatypes.

Division 

Division operation is used to perform the mathematical division of two variables. In programming, we refer to “/” as a symbol of division. Please note that Division can only be carried out on Integer, Float and Double datatypes.

Modulus 

Modulus operation is used to perform the mathematical remainder of two variables. In programming, we refer to “%” as a symbol of modulus. Modulus operator divides variable on the left to the variable on right and returns the remainder. Please note that modulus can only be carried out on integer and float datatypes in Python. For example, if there are two integer variables “x” and “y” declared in your program. Where x = 10, and y = 3. If we perform modulus operation on these variables in programming, the result is going to be 1.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...