C Program To Perform Simple Addition, Subtract, Multiplication, Division And Remainder Of Two Numbers

1. Addition Of Two Numbers:- 

Hello friends, in this post today, we will learn how we can combine the given two digits using C programming, for this, we first enter two digits and add using the + operator,  After adding, run this code then we get their sum.
Simple calculation

Read Also:
  1. Operators
  2. Conditions Statements
  3. Loops
For Example:- See the code written below for more information.

Output:-
Enter Two Numbers for Addition:
15
6
Sum of Two Numbers is:21

2. Subtraction Of Two Numbers:- 

In this program, we will learn how we can subtract of the given two digits using C programming, for this, we first enter two digits and subtract using the - (Minus) operator,  After subtract, run this code then we get their subtraction.
For Example:- See the code written below for more information.

Output:-
Enter Two Numbers for subtraction:
38
25
Sub of Two Numbers is:13

3. Multiplication Of Two Numbers:- 

In this program, we will learn how we can multiply of the given two digits using C programming, for this, we first enter two digits and multiply using the * operator,  After multiply, run this code then we get their multiplication.

For Example:- See the code written below for more information.

Output:-
Enter Two Numbers for multiplication:
8
6
Mul of Two Numbers is:48

4. Division Of Two Numbers:- 


In this program, we will learn how we can division of the given two digits using C programming, for this, we first enter two digits and divide using the / operator,  After division, run this code then we get their division.
For Example:- See the code written below for more information.

Output:-
Enter Two Numbers for division:
72
8
Division of Two Numbers is:9

5. Remainder Of Two Numbers:- 


In this program, we will learn how we can find the remainder of the given two digits using C programming, for this, we first enter two digits using the % operator,  After runing this code, we get remainder of the numbers.
For Example:- See the code written below for more information.

Output:-
Enter Two Numbers for remainder:
65
8
Remainder of Two Numbers is:1


In the above programs, we are need few things to explain which are as follow:
  • In the first line #include<stdio.h> allow the program to the file of  PC, #include is preprocessor directive, it include the information to exicute specific functions from specified header files. The space between # and include is not allow at compile time.
  • In the second line main() is main function. Every program contains a function which called main function. It declear the start of the function. Curly brackets({}) use to start and close functions, it uses to group statements togather in functions, which called a block.
  • In the next line, N1, N2 and Sum are the variables name or variables declaration. These use to store numeric data. Int is a integer data type, which store integer number like 1,2,3,9,4 etc.
  • Next is printf("......"); Here printf is buil in function in C, used to print(output) keywords on the screan, bracket uses to write a statement between brackets. Double quotes use to inclosed printed text in double quotes. Very importante notes is that every compound statement ends with semicolon (;).
  • Next is scanf("%d", &Sum); Like printf, scanf is a built in function in c. It uses to read the value of the entered variables and assigns the value to specified variables. %d in the scanf or printf functions tells to the compiler that the value of  the variables should read or print as a integer. The ampersand (&) is an oprator which used to specifies the address of variables.
  • Next is Sum=N1+N2; This is a particular type of expression statement which called assigment statement. This causes to addition to calculation from given numbers, plus signed(+) indicates the additional of numbers.
  • Next is printf(".....%d",sum); I have already talk you about printf, double quotes, %d etch. Here %d used to print integer number which is sum i.e, sum is a integer number.
  • Next and final step is return statement, it used to return a value.

Post a Comment

1 Comments