Jul 28, 2020

IT for Business Malayalam Tutorial | MG University BCom CA | Introduction to IT | Module1 | Part1

Click Here to get Powerpoint Presentation : IT For Business (MGU BCom Computer)- Module1-Part01

C Program for Beginners | Simple Calculator | Addition | Subtraction | M...

Simple calculation Program (Addition, Subtraction, Multiplication, Division)

Sum of two numbers
#include <stdio.h>
#include <conio.h>
int main()
{
   int a, b, sum;
printf("Enter the first number: ");
scanf("%d",&a);
printf("Enter the second number: ");
scanf("%d",&b);
//printf("Enter two no: ");
//scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum : %d", sum);
return(0);
}
Output
Enter the first number: 5
Enter the second number: 6
Sum : 11

Subtraction of two numbers
#include <stdio.h>
int main()
{
   int a, b, Substraction;
printf("\nEnter two no: ");
scanf("%d %d", &a, &b);
Substraction = a - b;
printf("Result : %d", Substraction);
return(0);
}
Output
Enter two no: 8    2
Result : 6

Multiplication of two numbers
#include <stdio.h>
int main()
{
   int a, b, Multiplication;
printf("\nEnter two no: ");
scanf("%d %d", &a, &b);
Multiplication = a * b;
printf("Result : %d", Multiplication);
return(0);
}
Output
Enter two no: 8    2
Result : 16

Division of two numbers
#include <stdio.h>
int main() 
{
   int a, b, Division;
printf("\nEnter two no: ");
scanf("%d %d", &a, &b);
Division = a / b;
printf("Result : %d", Division);
return(0);
}
Output
Enter two no: 8    2
Result : 4

Addition, Subtraction, Multiplication, Division of two numbers(Single Program)
#include <stdio.h>
int main() {
    // printf() displays the string inside quotation
     
     float a,b;

printf("Enter the two numbers: ");
scanf("%f %f", &a, &b);
printf("sum = %f",(a+b));
printf("\nsub = %f",(a-b));
printf("\nmul = %f",(a*b));
printf("\ndiv = %f",(a/b));
return 0;
}
Output
Enter the two numbers: 15  2
sum = 17.000000
sub = 13.000000
mul = 30.000000
div = 7.500000