Perform Addition, Subtraction, Multiplication, and Division : C Program

Computer Science » C Program » Perform Addition, Subtraction, Multiplication, and Division

Program :

#include <stdio.h>
 
int main()
{
   int num1, num2, add, sub, mul;
   float div;
 
   printf("Enter two integer numbers : n");
   scanf("%d%d", &num1, &num2);
 
   add = num1 + num2;
   sub = num1 - num2;
   mul = num1 * num2;
   div = num1 / (float)num2; 
 
   printf("nSum = %d",add);
   printf("nDifference = %d",sub);
   printf("nMultiplication = %d",mul);
   printf("nDivision = %.2f",div);
 
   return 0;
}

Output :

Enter two integer numbers : 
20
10
Sum = 30
Difference = 10
Multiplication = 200
Division = 2.00
Subject Name : Computer Science
Exam Name : IIT GATE, UPSC ESE, RRB, SSC, DMRC, NMRC, BSNL, DRDO, ISRO, BARC, NIELIT
Posts Name : Assistant Engineer, Management Trainee, Junior Engineer, Technical Assistant
Computer Science Books

GATE 2023 Total InfoENGG DIPLOMAUGC NET Total Info
IES 2023 Total InfoPSUs 2022 Total InfoCSIR UGC NET Total Info
JAM 2023 Total InfoM TECH 2023 Total InfoRAILWAY 2022 Total Info

Related Posts

  • C Program ExamplesComputer Science » C Program » C Program Examples "How to print hello, world! using c program ? How to find area of a circle using c program ? How to find smallest element in an array using c program ? You all must have this kind of questions in your mind. Below article will solve this puzzle of yours. Just take a look.”  - Here we have listed all the programs in C programming language, categorised under different progamming concepts like Basic, Area, Mathematical, Number, Array etc. Check the respective category to view all the programs under that category. C Programs - Basic C Programs C Programs - Number Programs C Programs - Area Programs C Programs - Mathematical Programs C Programs - Array Programs C Programs - Electrical Programs C Programs - Pyramid Programs
    Tags: programs, program, computer, science
  • Pyramid of Multiplication Tables : C ProgramComputer Science » C Program » Pyramid of Multiplication Tables Program : [php]#include<stdio.h> int main() { int i, j; for (i = 0; i <= 6; i++) { for (j = 0; j <= i; j++) { printf("%dt", i * j); } printf("n"); } return(0); }[/php] Output : [php]0 0 1 0 2 4 0 3 6 9 0 4 8 12 16 0 5 10 15 20 25 0 6 12 18 24 30 36 [/php]
    Tags: program, multiplication, computer, science, output, programs
  • Swap Two Numbers Without using Third Variable : C ProgramComputer Science » C Program » Swap Two Numbers Without using Third Variable  Program : [php]#include<stdio.h> int main() { int a, b; printf("nEnter value for num1 & num2 : "); scanf("%d %d", &a, &b); a = a + b; b = a - b; a = a - b; printf("nAfter swapping value of a : %d", a); printf("nAfter swapping value of b : %d", b); return (0); }[/php] Output : [php]Enter value for num1 & num2 : 1 2 After swapping value of a : 2 After swapping value of b : 1[/php]
    Tags: program, computer, science, output, programs
  • Rectangle using Line and Special Symbols : C ProgramComputer Science » C Program » Rectangle using Line and Special Symbols Program : [php]#include<stdio.h> int main() { int i, j; for (i = 0; i < 10; i++) { printf("n"); for (j = 0; j < 10; j++) { if (i == 0 || i == 9 || j == 0 || j == 9) printf("▲"); else printf("-"); } } return (0); }[/php] Output : [php]▲▲▲▲▲▲▲▲▲▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲▲▲▲▲▲▲▲▲▲[/php]
    Tags: program, computer, science, output, programs
  • Find the Number of Elements in An Array : C ProgramComputer Science » C Program » Find the Number of Elements in An Array Program : [php]#include <stdio.h> int main() { int array[] = {10, 20, 30, 40, 50, 60, 70,80,90,100}; int n,m; n = sizeof(array); m = n/sizeof(int); printf("Size of the given array is : %d", m); return 0; }[/php] Output : [php]Size of the given array is : 10[/php]
    Tags: program, computer, science, output, programs

LEAVE A REPLY

Please enter your comment!
Please enter your name here