-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp-1-2.c
More file actions
50 lines (44 loc) · 1.06 KB
/
exp-1-2.c
File metadata and controls
50 lines (44 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*************************************************************************
> File Name: exp-1-2.c
> Author: xiaoxiaoh
> Mail: xiaoxxhao@gmail.com
> Created Time: Mon Jun 26 15:35:20 2017
************************************************************************/
/*
* Write a C program to enter two numbers and perform all arithmetic operations.
*
* Example
*
* Input
* First number: 10
* Second number: 5
*
* Output
* Sum = 15
* Difference = 5
* Product = 50
* Quotient = 2
* Modulus = 0
*/
#include <stdio.h>
int main()
{
int num1, num2;
int sum, sub, mult, div, mod;
/* read two numbers from user*/
printf("Enter any two numbers:");
scanf("%d%d", &num1, &num2);
/* performs all arithmetic operations*/
sum = num1 + num2;
sub = num1 - num2;
mult = num1 * num2;
div = (float)num1 /num2;
mod = num1 %num2;
/* print all the result of all arithmetic operations*/
printf("sum = %d\n", sum);
printf("difference = %d\n", sub);
printf("product = %d\n", mult);
printf("quotient = %d\n", div);
printf("modules = %d\n",mod);
return 0;
}