In this blog we will learn how to perform arithmetic operation in c of two numbers.
Logic to solve code
1. Input the two numbers.
2. Then, perform the all operation one by one.
3. Finally print all the values after all operation.
Full Code of Performing all Arithmetic Operation of two numbers.
/*
* Program to find the all arithmetic operation of two numbers */ #include<stdio.h> int main() { int a, b, Sum, Subtract, Multiply, Divide; /* a and b for two numbers and others for the same */ printf("Enter the first number\n"); // Input the first number scanf("%d",&a); printf("Enter the second number\n"); // Input the second number scanf("%d",&b); Sum = a + b; //this perform the sum // For printing the sum values printf("Sum of two numbers %d and %d is %d.\n",a,b,Sum); Subtract = a - b; //this perform the subtraction // For printing the subtraction values printf("Subtraction of two numbers %d and %d is %d.\n",a,b,Subtract); Multiply = a * b; //this perform the multipication // For printing the multiplication values printf("Multiplication of two numbers %d and %d is %d.\n",a,b,Multiply); Divide = a/b; //this perform the division // For printing the division values printf("Division of two numbers %d and %d is %d.",a,b,Divide); return 0; }
\n is used for changing the line. After enter the values and after performing the operations.
I hope you know very well how to add two numbers in C language. If you like this posts. Then, Please Comment Us!
0 Comments