C program to perform the arithmetic operations by accepting the inputs
Algorithm
Step 1: Start
Step 2: Declare a,bandc
Step 3: Read the values of two numbers,and store in variable aandb
Step 4: Perform the arithmetic operations
c=a+b(Addition)c=a-b(Subtraction)c=a * b(Multiplication)c=a / b(Division)c=(a+b) / 2(Average)
Step 5: Print the results
Step 6: End
kw.c
#include<stdio.h>intmain(){floata,b,c;printf("———————————————————————————————————————————");printf("\nProgram to perform arithmetic operations");printf("\n———————————————————————————————————————————");printf("\nEnter the 1st number ");scanf("%f",&a);printf("\nEnter the 2nd number ");scanf("%f",&b);printf("———————————————————————————");c=a+b;printf("\n Addition | %f",c);c=a-b;printf("\n Subtraction | %f",c);c=a*b;printf("\nMultiplication | %f",c);c=a/b;printf("\n Division | %f",c);printf("\n———————————————————————————\n");c=(a+b)/2;printf("\nAverage of two numbers is %f",c);printf("\n———————————————————————————————————————————\n");return0;}
Output
kodingwindow@kw:~$ gcc kw.c kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to perform arithmetic operations
———————————————————————————————————————————
Enter the 1st number 25
Enter the 2nd number -5
———————————————————————————
Addition | 20.000000
Subtraction | 30.000000
Multiplication | -125.000000
Division | -5.000000
———————————————————————————
Average of two numbers is 10.000000
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?