Arithmetic operations in C programming

ALGORITHM: 

    1. Start 

    2. Declare variables 

    3. Read the Inputs . 

    4. Calculate Arithmetic operations(+,-,*,/,pow) for the input of two numbers. 

    5. Display the output of the calculations . 

    6. Stop

PROGRAM:

#include <stdio.h>
#include <conio.h>
int main(){
 int firstNumber, secondNumber;
 int sum, difference, product;
 long square;
 float quotient;
 printf("Enter First Number: ");
 scanf("%d",&firstNumber);
 printf("Enter Second Number: ");
 scanf("%d", &secondNumber);
 sum = firstNumber + secondNumber;
 difference = firstNumber - secondNumber;
 product = firstNumber * secondNumber;
 quotient = (float)firstNumber / secondNumber;
square = firstNumber *firstNumber;
 printf("\nSum = %d", sum);
 printf("\nDifference = %d", difference);
 printf("\nMultiplication = %d", product);
 printf("\nDivision = %.3f", quotient);
 printf("\n Square= %ld", square);
 getch();
 return 0;
}

Output:

Enter First Number: 25
Enter Second Number: 4
Sum = 29
Difference = 21
Multiplication = 100
Division = 6.250
Square = 625

Leave a comment